Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-08-19 07:32:41
Exec Total Coverage
Lines: 12400 19889 62.3%
Functions: 259 354 73.2%
Branches: 10528 22093 47.7%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // ZQuest Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #include <string.h>
16 #include <set>
17 #include <stdio.h>
18
19 #include "base/qrs.h"
20 #include "base/dmap.h"
21 #include "zc/hero.h"
22 #include "zc/guys.h"
23 #include "subscr.h"
24 #include "zc/zc_subscr.h"
25 #include "zc/decorations.h"
26 #include "gamedata.h"
27 #include "zc/zc_custom.h"
28 #include "zc/title.h"
29 #include "zc/ffscript.h"
30 #include "drawing.h"
31 #include "zc/combos.h"
32 #include "base/zc_math.h"
33 #include "user_object.h"
34 #include "slopes.h"
35 #include "zinfo.h"
36 #include "base/misctypes.h"
37 extern FFScript FFCore;
38 extern HeroClass Hero;
39 extern ZModule zcm;
40 extern zcmodule moduledata;
41 extern refInfo playerScriptData;
42 #include "zscriptversion.h"
43 #include "particles.h"
44 #include <fmt/format.h>
45 #include "zc/render.h"
46
47 extern refInfo *ri; //= NULL;
48 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
49 extern portal mirror_portal;
50 using std::set;
51
52 extern int32_t skipcont;
53
54 extern int32_t draw_screen_clip_rect_x1;
55 extern int32_t draw_screen_clip_rect_x2;
56 extern int32_t draw_screen_clip_rect_y1;
57 extern int32_t draw_screen_clip_rect_y2;
58
59 int32_t hero_count = -1;
60 int32_t hero_animation_speed = 1; //lower is faster animation
61 static int32_t z3step = 2;
62 116 static zfix hero_newstep(1.5);
63 116 static zfix hero_newstep_diag(1.5);
64 bool did_scripta=false;
65 bool did_scriptb=false;
66 bool did_scriptl=false;
67 byte lshift = 0;
68 int32_t dowpn = -1;
69 int32_t directItem = -1; //Is set if Hero is currently using an item directly
70 int32_t directItemA = -1;
71 int32_t directItemB = -1;
72 int32_t directItemX = -1;
73 int32_t directItemY = -1;
74 int32_t directWpn = -1;
75 int32_t whistleitem=-1;
76 extern int32_t script_hero_cset;
77
78 void playLevelMusic();
79
80 extern particle_list particles;
81
82 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
83
84 #define CANFORCEFACEUP (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
85 #define NO_GRIDLOCK (get_qr(qr_DISABLE_4WAY_GRIDLOCK)||get_qr(qr_NEW_HERO_MOVEMENT2))
86 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
87 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_qr(qr_BROKEN_Z3_ANIMATION))
88
89 1833 bool item_error()
90 {
91
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 24 times.
1833 if(QMisc.miscsfx[sfxERROR])
92 1809 sfx(QMisc.miscsfx[sfxERROR]);
93 1833 return false;
94 }
95 19539871 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
96 {
97
2/2
✓ Branch 0 taken 2773 times.
✓ Branch 1 taken 19537098 times.
19539871 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
98 19537098 return false;
99 19539871 }
100
101 6514779 static inline bool platform_fallthrough(bool doslopecheck = true)
102 {
103
5/6
✓ Branch 0 taken 6514779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6512767 times.
✓ Branch 3 taken 2012 times.
✓ Branch 4 taken 6512325 times.
✓ Branch 5 taken 442 times.
17844969 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
104
2/2
✓ Branch 0 taken 850576 times.
✓ Branch 1 taken 848564 times.
6514779 || (getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_qr(qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
105
6/6
✓ Branch 0 taken 4815525 times.
✓ Branch 1 taken 5666101 times.
✓ Branch 2 taken 339327 times.
✓ Branch 3 taken 6175338 times.
✓ Branch 4 taken 311990 times.
✓ Branch 5 taken 27337 times.
1699140 || (Hero.jumping < 0 && getInput(btnDown, false, get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_qr(qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
106 }
107
108 1553 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
109 {
110
3/4
✓ Branch 0 taken 1553 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 712 times.
✓ Branch 3 taken 841 times.
1553 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 712 times.
712 if(slopesmisc == 2) return false;
112
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
712 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
113
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
229 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
229 if (platform_fallthrough() && !ignoreFallthrough) return false;
115
2/4
✓ Branch 0 taken 229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229 times.
✗ Branch 3 not taken.
229 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
116
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 199 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
229 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
117 return true;
118 229 return false;
119 1553 }
120
121 9219664 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
122 {
123
4/4
✓ Branch 0 taken 1703993 times.
✓ Branch 1 taken 7515671 times.
✓ Branch 2 taken 1695744 times.
✓ Branch 3 taken 8249 times.
9219664 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
124
2/2
✓ Branch 0 taken 124819 times.
✓ Branch 1 taken 9086596 times.
9211415 if(slopesmisc == 2) return false;
125
4/4
✓ Branch 0 taken 6696560 times.
✓ Branch 1 taken 2390036 times.
✓ Branch 2 taken 181335 times.
✓ Branch 3 taken 6515225 times.
9086596 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
126
6/6
✓ Branch 0 taken 62264 times.
✓ Branch 1 taken 6452961 times.
✓ Branch 2 taken 4263 times.
✓ Branch 3 taken 58001 times.
✓ Branch 4 taken 3588 times.
✓ Branch 5 taken 675 times.
6515225 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
127
3/4
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 6514436 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
6514550 if (platform_fallthrough() && !ignoreFallthrough) return false;
128
3/4
✓ Branch 0 taken 722195 times.
✓ Branch 1 taken 5792241 times.
✓ Branch 2 taken 722195 times.
✗ Branch 3 not taken.
6514436 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
129
4/6
✓ Branch 0 taken 1870884 times.
✓ Branch 1 taken 4643552 times.
✓ Branch 2 taken 1870884 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1870884 times.
6514436 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
130 return true;
131 6514436 return false;
132 9219664 }
133
134 1331 void HeroClass::snap_platform()
135 {
136
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 849 times.
1331 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false) < 0)
137 849 return;
138
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
482 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN))
139 {
140 y = 160;
141 return;
142 }
143
2/4
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 482 times.
482 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
144 return;
145 482 movexy(0,1,false,true,false,false);
146 1331 }
147
148
149 20912835 bool usingActiveShield(int32_t itmid)
150 {
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20912835 times.
20912835 if(Hero.shieldjinxclk) return false;
152
2/2
✓ Branch 0 taken 2833056 times.
✓ Branch 1 taken 18079779 times.
20912835 switch(Hero.action) //filter allowed actions
153 {
154 case none: case walking: case rafting:
155 case gothit: case swimhit:
156 18079779 break;
157 2833056 default: return false;
158 }
159
3/4
✓ Branch 0 taken 2631 times.
✓ Branch 1 taken 18077148 times.
✓ Branch 2 taken 2631 times.
✗ Branch 3 not taken.
18079779 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18079779 times.
18079779 if(itmid < 0)
161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18079779 times.
18079779 itmid = (Hero.active_shield_id < 0
162 18079779 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
163
2/2
✓ Branch 0 taken 16495375 times.
✓ Branch 1 taken 1584404 times.
18079779 if(itmid < 0) return false;
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16495375 times.
16495375 if(item_disabled(itmid)) return false;
165
1/2
✓ Branch 0 taken 16495375 times.
✗ Branch 1 not taken.
16495375 if(!checkitem_jinx(itmid)) return false;
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16495375 times.
16495375 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
167 if(!isItmPressed(itmid)) return false;
168 return (checkbunny(itmid) && checkmagiccost(itmid));
169 20912835 }
170 13321288 int32_t getCurrentShield(bool requireActive)
171 {
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13321288 times.
13321288 if(Hero.shieldjinxclk) return -1;
173
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13321288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13321288 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
174 return Hero.active_shield_id;
175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13321288 times.
13321288 if(!requireActive) return current_item_id(itype_shield);
176 return -1;
177 13321288 }
178 88713 int32_t getCurrentActiveShield()
179 {
180 88713 int32_t id = Hero.active_shield_id;
181
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 88713 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
88713 if(id > -1 && usingActiveShield(id))
182 return id;
183 88713 return -1;
184 88713 }
185 7262487 int32_t refreshActiveShield()
186 {
187 7262487 int32_t id = -1;
188
2/2
✓ Branch 0 taken 7074196 times.
✓ Branch 1 taken 188291 times.
7262487 if(DrunkcBbtn())
189 {
190 188291 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 188291 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
188291 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
192 {
193 id = Bwpn&0xFFF;
194 }
195 188291 }
196
3/4
✓ Branch 0 taken 7262487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6581293 times.
✓ Branch 3 taken 681194 times.
7262487 if(id < 0 && DrunkcAbtn())
197 {
198 681194 itemdata const& dat = itemsbuf[Awpn&0xFFF];
199
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 681194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
681194 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
200 {
201 id = Awpn&0xFFF;
202 }
203 681194 }
204
3/4
✓ Branch 0 taken 7262487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7262206 times.
✓ Branch 3 taken 281 times.
7262487 if(id < 0 && DrunkcEx1btn())
205 {
206 281 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
207
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 281 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
281 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
208 {
209 id = Xwpn&0xFFF;
210 }
211 281 }
212
3/4
✓ Branch 0 taken 7262487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7261301 times.
✓ Branch 3 taken 1186 times.
7262487 if(id < 0 && DrunkcEx2btn())
213 {
214 1186 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
215
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1186 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1186 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
216 {
217 id = Ywpn&0xFFF;
218 }
219 1186 }
220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262487 times.
7262487 if(!usingActiveShield(id))
221 7262487 return -1;
222 return id;
223 7262487 }
224 static bool is_immobile()
225 {
226 if(!get_qr(qr_NEW_HERO_MOVEMENT))
227 return false;
228 zfix rate(Hero.steprate);
229 int32_t shieldid = getCurrentActiveShield();
230 if(shieldid > -1)
231 {
232 itemdata const& shield = itemsbuf[shieldid];
233 if(shield.flags & ITEM_FLAG10) //Change Speed flag
234 {
235 zfix perc = shield.misc7;
236 perc /= 100;
237 if(perc < 0)
238 perc = (perc*-1)+1;
239 rate = (rate * perc) + shield.misc8;
240 }
241 }
242 return rate != 0;
243 }
244
245 14572399 bool nomove_action(int action)
246 {
247
2/2
✓ Branch 0 taken 13974509 times.
✓ Branch 1 taken 597890 times.
14572399 switch(action)
248 {
249 case gothit:
250 case drowning:
251 case lavadrowning:
252 case sidedrowning:
253 case falling:
254 case freeze:
255 case sideswimfreeze:
256 case scrolling:
257 case casting:
258 case sideswimcasting:
259 case landhold1:
260 case landhold2:
261 case waterhold1:
262 case waterhold2:
263 case sidewaterhold1:
264 case sidewaterhold2:
265 case hopping:
266 case inwind:
267 597890 return true;
268 }
269 13974509 return false;
270 14572399 }
271
272 7439529 bool HeroClass::isStanding(bool forJump)
273 {
274
3/4
✓ Branch 0 taken 7434810 times.
✓ Branch 1 taken 4719 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7434810 times.
7439529 if(z || fakez) return false;
275
3/4
✓ Branch 0 taken 254145 times.
✓ Branch 1 taken 7180665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124888 times.
7559698 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)
276
4/6
✓ Branch 0 taken 124888 times.
✓ Branch 1 taken 129257 times.
✓ Branch 2 taken 124888 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124888 times.
✗ Branch 5 not taken.
254145 && !ladderx && !laddery && !getOnSideviewLadder())
277 124888 return false;
278
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 7309886 times.
7309922 if(hoverclk) return false;
279
2/2
✓ Branch 0 taken 297127 times.
✓ Branch 1 taken 7012759 times.
7309886 if(nomove_action(action)) return false;
280 7012759 int32_t val = check_pitslide();
281
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7012745 times.
7012759 if(val == -2) return false;
282
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 7012702 times.
7012745 if(val == -1) return true;
283 43 return forJump;
284 7439529 }
285 26524 bool HeroClass::isLifting()
286 {
287
2/2
✓ Branch 0 taken 1265 times.
✓ Branch 1 taken 25259 times.
26524 if(lift_wpn) return true;
288 25259 return false;
289 26524 }
290 17 void HeroClass::set_liftflags(int liftid)
291 {
292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(unsigned(liftid) >= MAXITEMS)
293 return;
294 17 itemdata const& itm = itemsbuf[liftid];
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & ITEM_FLAG3);
296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & ITEM_FLAG4);
297 17 }
298
299 45944 void HeroClass::set_respawn_point(bool setwarp)
300 {
301 45944 zfix oldx = x, oldy = y;
302
2/2
✓ Branch 0 taken 38399 times.
✓ Branch 1 taken 7545 times.
45944 if (replay_version_check(17))
303 {
304 7545 x = vbound(x,0,240);
305 7545 y = vbound(y,0,160);
306 7545 }
307
308 45944 do
309 {
310
2/2
✓ Branch 0 taken 37164 times.
✓ Branch 1 taken 8780 times.
45944 if(setwarp)
311 {
312 8780 warpx = x;
313 8780 warpy = y;
314 8780 raftwarpx = x;
315 8780 raftwarpy = y;
316 8780 }
317
2/2
✓ Branch 0 taken 21607 times.
✓ Branch 1 taken 24337 times.
45944 if(!get_qr(qr_OLD_RESPAWN_POINTS))
318 {
319 24337 bool is_safe = true;
320
2/2
✓ Branch 0 taken 22649 times.
✓ Branch 1 taken 1688 times.
24337 switch(action)
321 {
322 case none: case walking:
323 22649 break;
324 default:
325 1688 is_safe = false;
326 1688 }
327
2/2
✓ Branch 0 taken 22649 times.
✓ Branch 1 taken 1688 times.
24337 if(!is_safe) break; //unsafe action
328
5/6
✓ Branch 0 taken 22009 times.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 22009 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 21990 times.
22649 if(z > 0 || fakez > 0 || hoverclk) break; //in air
329
4/4
✓ Branch 0 taken 1553 times.
✓ Branch 1 taken 20437 times.
✓ Branch 2 taken 1324 times.
✓ Branch 3 taken 229 times.
21990 if(sideview_mode() && !on_sideview_solid(x,y,true)) break; //in air sideview
330
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 21746 times.
21761 if(check_pitslide(true) != -1) break; //On a pit
331
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 21735 times.
21746 if (ladderx+laddery) break; //on the ladder
332
333 { //Check water
334 21735 int32_t water = 0;
335 21735 int32_t types[4] = {0};
336 21735 int32_t x1 = x+4, x2 = x+11,
337 21735 y1 = y+9, y2 = y+15;
338
1/2
✓ Branch 0 taken 21735 times.
✗ Branch 1 not taken.
21735 if (get_qr(qr_SMARTER_WATER))
339 {
340
3/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 21701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
21736 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
341
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
342
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
343 1 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
344 21735 }
345 else
346 {
347 types[0] = COMBOTYPE(x1,y1);
348
349 if(MAPFFCOMBO(x1,y1))
350 types[0] = FFCOMBOTYPE(x1,y1);
351
352 types[1] = COMBOTYPE(x1,y2);
353
354 if(MAPFFCOMBO(x1,y2))
355 types[1] = FFCOMBOTYPE(x1,y2);
356
357 types[2] = COMBOTYPE(x2,y1);
358
359 if(MAPFFCOMBO(x2,y1))
360 types[2] = FFCOMBOTYPE(x2,y1);
361
362 types[3] = COMBOTYPE(x2,y2);
363
364 if(MAPFFCOMBO(x2,y2))
365 types[3] = FFCOMBOTYPE(x2,y2);
366
367 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
368 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
369 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
370
371 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
372 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
373 water = typec;
374 }
375
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21734 times.
21735 if(water > 0)
376 1 break;
377 } //End check water
378
379 108670 int poses[4] = {
380 21734 COMBOPOS(x,y+(bigHitbox?0:8)),
381 21734 COMBOPOS(x,y+15),
382 21734 COMBOPOS(x+15,y+(bigHitbox?0:8)),
383 21734 COMBOPOS(x+15,y+15)
384 };
385
2/2
✓ Branch 0 taken 20535 times.
✓ Branch 1 taken 83463 times.
103998 for(auto pos : poses)
386 {
387
2/2
✓ Branch 0 taken 82264 times.
✓ Branch 1 taken 1199 times.
83463 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
388 {
389 1199 is_safe = false;
390 1199 break;
391 }
392 }
393
2/2
✓ Branch 0 taken 20535 times.
✓ Branch 1 taken 1199 times.
21734 if(!is_safe) break;
394 20535 }
395 42142 respawn_x = x;
396 42142 respawn_y = y;
397 42142 respawn_scr = currscr;
398 42142 respawn_dmap = currdmap;
399 42142 }
400 while(false); //run once, but 'break' works
401
402 45944 x = oldx;
403 45944 y = oldy;
404 45944 }
405
406 17 void HeroClass::go_respawn_point()
407 {
408 17 x = respawn_x;
409 17 y = respawn_y;
410 17 handle_portal_prox(&mirror_portal);
411
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 portals.forEach([&](sprite& p)
412 {
413 handle_portal_prox((portal*)&p);
414 return false;
415 });
416 17 warpx=x;
417 17 warpy=y;
418 17 raftwarpx = x;
419 17 raftwarpy = y;
420 17 trySideviewLadder(); //Cling to ladder automatically
421
422
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12 times.
17 if(get_qr(qr_OLD_RESPAWN_POINTS))
423 12 return; //No cross-screen return
424
425
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if(currdmap != respawn_dmap || currscr != respawn_scr)
426 {
427 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
428 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
429 }
430 17 }
431
432 14994 void HeroClass::trySideviewLadder()
433 {
434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14994 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14994 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
435 setOnSideviewLadder(true);
436 14994 }
437
438 33241251 bool HeroClass::can_pitfall(bool ignore_hover)
439 {
440
27/30
✓ Branch 0 taken 32651279 times.
✓ Branch 1 taken 589972 times.
✓ Branch 2 taken 32444408 times.
✓ Branch 3 taken 206871 times.
✓ Branch 4 taken 32436590 times.
✓ Branch 5 taken 7818 times.
✓ Branch 6 taken 32436590 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 32436506 times.
✓ Branch 9 taken 84 times.
✓ Branch 10 taken 32436506 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 70 times.
✓ Branch 13 taken 32436436 times.
✓ Branch 14 taken 32427159 times.
✓ Branch 15 taken 9347 times.
✓ Branch 16 taken 32426292 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 32425046 times.
✓ Branch 19 taken 1246 times.
✓ Branch 20 taken 32340209 times.
✓ Branch 21 taken 84837 times.
✓ Branch 22 taken 31884646 times.
✓ Branch 23 taken 455563 times.
✓ Branch 24 taken 31884366 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 31884366 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1280 times.
✓ Branch 29 taken 31883086 times.
33241251 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
441 }
442
443 4188793 int32_t HeroClass::DrunkClock()
444 {
445 4188793 return drunkclk;
446 }
447 void HeroClass::setDrunkClock(int32_t newdrunkclk)
448 {
449 drunkclk=newdrunkclk;
450 }
451
452 int32_t HeroClass::StunClock()
453 {
454 return lstunclock;
455 }
456 void HeroClass::setStunClock(int32_t v)
457 {
458 lstunclock=v;
459 }
460
461 114964553 int32_t HeroClass::BunnyClock()
462 {
463 114964553 return lbunnyclock;
464 }
465 void HeroClass::setBunnyClock(int32_t v)
466 {
467 lbunnyclock=v;
468 }
469
470
11/22
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 116 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 116 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 116 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 116 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 116 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 116 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 116 times.
✗ Branch 21 not taken.
348 HeroClass::HeroClass() : sprite()
471 232 {
472 116 lift_wpn = nullptr;
473
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 init();
474 116 }
475
476 //2.6
477
478 //Stop the subscreen from falling. -Z
479
480 754 bool HeroClass::stopSubscreenFalling(){
481 754 return preventsubscreenfalling;
482 }
483
484 void HeroClass::stopSubscreenFalling(bool v){
485 preventsubscreenfalling = v;
486 }
487
488
489 //Set the button items by brute force
490
491 void HeroClass::setAButtonItem(int32_t itmslot){
492 game->awpn = itmslot;
493 }
494
495 void HeroClass::setBButtonItem(int32_t itmslot){
496 game->bwpn = itmslot;
497 }
498
499 7262873 void HeroClass::ClearhitHeroUIDs()
500 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
501 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
502 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
503 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
504 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
505 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
506 //clear it on the next frame, but that had the SAME outcome.
507 //Where and how can I clear a value at the end of every frame, so that:
508 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
509 // 2. FFCs can read it before Waitframe. --same.
510 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
511
2/2
✓ Branch 0 taken 123468841 times.
✓ Branch 1 taken 7262873 times.
130731714 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
512 {
513 /*
514 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
515 {
516 //Z_scripterrlog("frame is: %d\n", frame);
517 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
518 lastHitBy[q][0] = 0;
519 }
520 */
521 123468841 lastHitBy[q][0] = 0;
522 123468841 }
523 7262873 }
524
525 37852 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
526 {
527 37852 lastHitBy[type][0] = screen_index;
528 37852 }
529
530 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
531 {
532 2929 return lastHitBy[type][0];
533 }
534
535 void HeroClass::set_defence(int32_t type, int32_t v)
536 {
537 defence[type] = v;
538 }
539
540 int32_t HeroClass::get_defence(int32_t type)
541 {
542 return defence[type];
543 }
544
545
546 //Set Hero;s hurt sfx
547 void HeroClass::setHurtSFX(int32_t sfx)
548 {
549 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
550 }
551 7661 int32_t HeroClass::getHurtSFX()
552 {
553 7661 return QMisc.miscsfx[sfxHURTPLAYER];
554 }
555
556 bool HeroClass::getDiagMove()
557 {
558 return diagonalMovement;
559 }
560 void HeroClass::setDiagMove(bool newdiag)
561 {
562 diagonalMovement=newdiag;
563 }
564 9024 bool HeroClass::getBigHitbox()
565 {
566 9024 return bigHitbox;
567 }
568 529 void HeroClass::setBigHitbox(bool newbigHitbox)
569 {
570 529 bigHitbox=newbigHitbox;
571 529 syofs = bigHitbox?0:8;
572 529 sysz_ofs = bigHitbox?0:-8;
573 529 }
574 5424 int32_t HeroClass::getStepRate()
575 {
576 5424 return steprate;
577 }
578 void HeroClass::setStepRate(int32_t newrate)
579 {
580 steprate = newrate;
581 }
582 int32_t HeroClass::getSwimUpRate()
583 {
584 return game->get_sideswim_up();
585 }
586 void HeroClass::setSwimUpRate(int32_t newrate)
587 {
588 game->set_sideswim_up(newrate);
589 }
590 int32_t HeroClass::getSwimSideRate()
591 {
592 return game->get_sideswim_side();
593 }
594 void HeroClass::setSwimSideRate(int32_t newrate)
595 {
596 game->set_sideswim_side(newrate);
597 }
598 int32_t HeroClass::getSwimDownRate()
599 {
600 return game->get_sideswim_down();
601 }
602 void HeroClass::setSwimDownRate(int32_t newrate)
603 {
604 game->set_sideswim_down(newrate);
605 }
606
607
608 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
609 5303380 void HeroClass::herostep()
610 {
611
2/2
✓ Branch 0 taken 4892872 times.
✓ Branch 1 taken 410508 times.
5303380 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
612 //need to run all global/hero/dmap scripts here?
613 5303380 }
614
615 76784 bool is_moving()
616 {
617
6/6
✓ Branch 0 taken 62175 times.
✓ Branch 1 taken 14609 times.
✓ Branch 2 taken 46632 times.
✓ Branch 3 taken 15543 times.
✓ Branch 4 taken 19527 times.
✓ Branch 5 taken 27105 times.
76784 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
618 }
619
620 // called by ALLOFF()
621 16475 void HeroClass::resetflags(bool all)
622 {
623 16475 refilling=REFILL_NONE;
624 16475 inwallm=false;
625 16475 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
626 16475 usecounts.clear();
627
628
4/4
✓ Branch 0 taken 16427 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 121 times.
✓ Branch 3 taken 16306 times.
16475 if(swordclk>0 || all)
629 {
630 169 swordclk=0;
631 169 verifyAWpn();
632 169 }
633
4/4
✓ Branch 0 taken 16467 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 121 times.
✓ Branch 3 taken 16346 times.
16475 if(itemclk>0 || all)
634 129 itemclk=0;
635
3/4
✓ Branch 0 taken 16475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121 times.
✓ Branch 3 taken 16354 times.
16475 if(shieldjinxclk>0 || all)
636 121 shieldjinxclk=0;
637
638
2/2
✓ Branch 0 taken 16354 times.
✓ Branch 1 taken 121 times.
16475 if(all)
639 {
640 121 DivineProtectionShieldClk=0;
641
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(div_prot_item != -1)
643 {
644 stop_sfx(itemsbuf[div_prot_item].usesound);
645 stop_sfx(itemsbuf[div_prot_item].usesound+1);
646 }
647
648 121 div_prot_item = -1;
649 121 hoverclk=jumping=0;
650 121 hoverflags = 0;
651 121 }
652 16475 damageovertimeclk = 0;
653 16475 newconveyorclk = 0;
654 16475 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
655
2/2
✓ Branch 0 taken 16475 times.
✓ Branch 1 taken 115325 times.
131800 for(auto q = 0; q < 7; ++q)
656 115325 hooked_undercombos[q] = -1;
657 16475 hopclk=0;
658 16475 hopdir=-1;
659 16475 attackclk=0;
660 16475 stomping=false;
661 16475 reset_swordcharge();
662 16475 diveclk=drownclk=drownCombo=0;
663 16475 action=none; FFCore.setHeroAction(none);
664 16475 conveyor_flags=0;
665 16475 magiccastclk=0;
666 16475 magicitem=-1;
667 16475 }
668
669 //Can use this for Hero->Stun. -Z
670 8119 void HeroClass::Freeze()
671 {
672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8119 times.
8119 if (action != inwind)
673 {
674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8119 times.
8119 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
675 8119 else {action=freeze; FFCore.setHeroAction(freeze);}
676 // also cancel Hero's attack
677 8119 attackclk = 0;
678 8119 }
679 8119 }
680 1739 void HeroClass::unfreeze()
681 {
682
3/4
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 983 times.
✓ Branch 2 taken 756 times.
✗ Branch 3 not taken.
1739 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1739 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
684 1739 }
685
686 10 void HeroClass::Drown(int32_t state)
687 {
688 // Hero should never drown if the ladder is out
689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(ladderx+laddery)
690 return;
691
692 10 drop_liftwpn();
693
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 switch(state)
694 {
695 case 1:
696 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
697 attackclk=0;
698 attack=wNone;
699 attackid=-1;
700 reset_swordcharge();
701 drownclk=64;
702 z=fakez=fall=fakefall=0;
703 break;
704
705
706 default:
707 {
708
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if (isSideViewHero() && get_qr(qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
709 10 else {action=drowning; FFCore.setHeroAction(drowning);}
710 10 attackclk=0;
711 10 attack=wNone;
712 10 attackid=-1;
713 10 reset_swordcharge();
714 10 drownclk=64;
715 10 z=fakez=fall=fakefall=0;
716 10 break;
717 }
718 }
719
720 10 }
721
722 1296 void HeroClass::finishedmsg()
723 {
724 //these are to cancel out any keys that Hero may
725 //be pressing so he doesn't attack at the end of
726 //a message if he was scrolling through it quickly.
727 1296 rAbtn();
728 1296 rBbtn();
729 1296 unfreeze();
730
731
3/4
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1279 times.
2575 if(action == landhold1 ||
732
1/2
✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
1280 action == landhold2 ||
733
1/2
✓ Branch 0 taken 1280 times.
✗ Branch 1 not taken.
1280 action == waterhold1 ||
734
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 1 times.
1280 action == waterhold2 ||
735
1/2
✓ Branch 0 taken 1279 times.
✗ Branch 1 not taken.
1279 action == sidewaterhold1 ||
736 1279 action == sidewaterhold2)
737 {
738 17 holdclk = 1;
739 17 }
740 1296 }
741 35 void HeroClass::setEaten(int32_t i)
742 {
743 35 inlikelike=i;
744 35 }
745 32 int32_t HeroClass::getEaten()
746 {
747 32 return inlikelike;
748 }
749 17905405 zfix HeroClass::getX()
750 {
751 17905405 return x;
752 }
753 17324193 zfix HeroClass::getY()
754 {
755 17324193 return y;
756 }
757 45886200 zfix HeroClass::getZ()
758 {
759 45886200 return z;
760 }
761 29949152 zfix HeroClass::getFakeZ()
762 {
763 29949152 return fakez;
764 }
765 641181 zfix HeroClass::getFall()
766 {
767 641181 return fall;
768 }
769 zfix HeroClass::getFakeFall()
770 {
771 return fakefall;
772 }
773 zfix HeroClass::getXOfs()
774 {
775 return xofs;
776 }
777 zfix HeroClass::getYOfs()
778 {
779 return yofs;
780 }
781 void HeroClass::setXOfs(int32_t newxofs)
782 {
783 xofs=newxofs;
784 }
785 void HeroClass::setYOfs(int32_t newyofs)
786 {
787 yofs=newyofs;
788 }
789 int32_t HeroClass::getHXOfs()
790 {
791 return hxofs;
792 }
793 int32_t HeroClass::getHYOfs()
794 {
795 return hyofs;
796 }
797 int32_t HeroClass::getHXSz()
798 {
799 return hit_width;
800 }
801 int32_t HeroClass::getHYSz()
802 {
803 return hit_height;
804 }
805 41408 zfix HeroClass::getClimbCoverX()
806 {
807 41408 return climb_cover_x;
808 }
809 41408 zfix HeroClass::getClimbCoverY()
810 {
811 41408 return climb_cover_y;
812 }
813 int32_t HeroClass::getLadderX()
814 {
815 return ladderx;
816 }
817 int32_t HeroClass::getLadderY()
818 {
819 return laddery;
820 }
821
822 445959 void HeroClass::setX(int32_t new_x)
823 {
824 445959 zfix dx=new_x-x;
825 445959 justmoved = 2;
826
1/2
✓ Branch 0 taken 445959 times.
✗ Branch 1 not taken.
445959 if(Lwpns.idFirst(wHookshot)>-1)
827 {
828 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
829 hs_startx+=(int32_t)dx;
830 }
831
832
1/2
✓ Branch 0 taken 445959 times.
✗ Branch 1 not taken.
445959 if(Lwpns.idFirst(wHSHandle)>-1)
833 {
834 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
835 }
836
837
1/2
✓ Branch 0 taken 445959 times.
✗ Branch 1 not taken.
445959 if(chainlinks.Count()>0)
838 {
839 for(int32_t j=0; j<chainlinks.Count(); j++)
840 {
841 chainlinks.spr(j)->x+=dx;
842 }
843 }
844
845 445959 x=new_x;
846
847 // A kludge
848
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 443415 times.
✓ Branch 2 taken 1591 times.
✓ Branch 3 taken 953 times.
445959 if(!diagonalMovement && dir<=down)
849 953 is_on_conveyor=true;
850 445959 }
851
852 460437 void HeroClass::setY(int32_t new_y)
853 {
854 460437 zfix dy=new_y-y;
855 460437 justmoved = 2;
856
1/2
✓ Branch 0 taken 460437 times.
✗ Branch 1 not taken.
460437 if(Lwpns.idFirst(wHookshot)>-1)
857 {
858 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
859 hs_starty+=(int32_t)dy;
860 }
861
862
1/2
✓ Branch 0 taken 460437 times.
✗ Branch 1 not taken.
460437 if(Lwpns.idFirst(wHSHandle)>-1)
863 {
864 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
865 }
866
867
1/2
✓ Branch 0 taken 460437 times.
✗ Branch 1 not taken.
460437 if(chainlinks.Count()>0)
868 {
869 for(int32_t j=0; j<chainlinks.Count(); j++)
870 {
871 chainlinks.spr(j)->y+=dy;
872 }
873 }
874
875 460437 y=new_y;
876
877 // A kludge
878
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 457893 times.
✓ Branch 2 taken 953 times.
✓ Branch 3 taken 1591 times.
460437 if(!diagonalMovement && dir>=left)
879 1591 is_on_conveyor=true;
880 460437 }
881
882 2 void HeroClass::setZ(int32_t new_z)
883 {
884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
885 return;
886
887
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
888 {
889
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
890 {
891 case swimming:
892 {
893 diveclk=0;
894 action=walking; FFCore.setHeroAction(walking);
895 break;
896 }
897
898 case waterhold1:
899 {
900 action=landhold1; FFCore.setHeroAction(landhold1);
901 break;
902 }
903
904 case waterhold2:
905 {
906 action=landhold2; FFCore.setHeroAction(landhold2);
907 break;
908 }
909
910 default:
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
912 {
913 reset_swordcharge();
914 attackclk=0;
915 }
916
917 2 break;
918 }
919 2 }
920
921
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
922 2 }
923
924 void HeroClass::setFakeZ(int32_t new_z)
925 {
926 if(isSideViewHero())
927 return;
928
929 if(fakez==0 && new_z > 0)
930 {
931 switch(action)
932 {
933 case swimming:
934 {
935 diveclk=0;
936 action=walking; FFCore.setHeroAction(walking);
937 break;
938 }
939
940 case waterhold1:
941 {
942 action=landhold1; FFCore.setHeroAction(landhold1);
943 break;
944 }
945
946 case waterhold2:
947 {
948 action=landhold2; FFCore.setHeroAction(landhold2);
949 break;
950 }
951
952 default:
953 if(charging) //!DIMITODO: Let Hero jump while charging sword
954 {
955 reset_swordcharge();
956 attackclk=0;
957 }
958
959 break;
960 }
961 }
962
963 fakez=(new_z>0 ? new_z : 0);
964 }
965
966 1210 void HeroClass::setXfix(zfix new_x)
967 {
968 //Z_scripterrlog("setxdbl: %f\n",new_x);
969 1210 zfix dx=new_x-x;
970 1210 justmoved = 2;
971
1/2
✓ Branch 0 taken 1210 times.
✗ Branch 1 not taken.
1210 if(Lwpns.idFirst(wHookshot)>-1)
972 {
973 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
974 hs_startx+=(int32_t)dx;
975 }
976
977
1/2
✓ Branch 0 taken 1210 times.
✗ Branch 1 not taken.
1210 if(Lwpns.idFirst(wHSHandle)>-1)
978 {
979 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
980 }
981
982
1/2
✓ Branch 0 taken 1210 times.
✗ Branch 1 not taken.
1210 if(chainlinks.Count()>0)
983 {
984 for(int32_t j=0; j<chainlinks.Count(); j++)
985 {
986 chainlinks.spr(j)->x+=dx;
987 }
988 }
989
990 1210 x=new_x;
991
992 // A kludge
993
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1210 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1210 if(!diagonalMovement && dir<=down)
994 is_on_conveyor=true;
995 1210 }
996
997 1071 void HeroClass::setYfix(zfix new_y)
998 {
999 1071 zfix dy=new_y-y;
1000 1071 justmoved = 2;
1001
1/2
✓ Branch 0 taken 1071 times.
✗ Branch 1 not taken.
1071 if(Lwpns.idFirst(wHookshot)>-1)
1002 {
1003 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1004 hs_starty+=(int32_t)dy;
1005 }
1006
1007
1/2
✓ Branch 0 taken 1071 times.
✗ Branch 1 not taken.
1071 if(Lwpns.idFirst(wHSHandle)>-1)
1008 {
1009 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1010 }
1011
1012
1/2
✓ Branch 0 taken 1071 times.
✗ Branch 1 not taken.
1071 if(chainlinks.Count()>0)
1013 {
1014 for(int32_t j=0; j<chainlinks.Count(); j++)
1015 {
1016 chainlinks.spr(j)->y+=dy;
1017 }
1018 }
1019
1020 1071 y=new_y;
1021
1022 // A kludge
1023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1071 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1071 if(!diagonalMovement && dir>=left)
1024 is_on_conveyor=true;
1025 1071 }
1026
1027 2767 void HeroClass::setZfix(zfix new_z)
1028 {
1029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
1030 return;
1031
1032
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
1033 {
1034
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
1035 {
1036 case swimming:
1037 {
1038 diveclk=0;
1039 action=walking; FFCore.setHeroAction(walking);
1040 break;
1041 }
1042
1043 case waterhold1:
1044 {
1045 action=landhold1; FFCore.setHeroAction(landhold1);
1046 break;
1047 }
1048
1049 case waterhold2:
1050 {
1051 action=landhold2; FFCore.setHeroAction(landhold2);
1052 break;
1053 }
1054
1055 default:
1056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
1057 {
1058 reset_swordcharge();
1059 attackclk=0;
1060 }
1061
1062 7 break;
1063 }
1064 7 }
1065
1066
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1067 2767 }
1068
1069 void HeroClass::setFakeZfix(zfix new_z)
1070 {
1071 if(isSideViewHero())
1072 return;
1073
1074 if(fakez==0 && new_z > 0)
1075 {
1076 switch(action)
1077 {
1078 case swimming:
1079 {
1080 diveclk=0;
1081 action=walking; FFCore.setHeroAction(walking);
1082 break;
1083 }
1084
1085 case waterhold1:
1086 {
1087 action=landhold1; FFCore.setHeroAction(landhold1);
1088 break;
1089 }
1090
1091 case waterhold2:
1092 {
1093 action=landhold2; FFCore.setHeroAction(landhold2);
1094 break;
1095 }
1096
1097 default:
1098 if(charging) //!DIMITODO: Let Hero jump while charging sword
1099 {
1100 reset_swordcharge();
1101 attackclk=0;
1102 }
1103
1104 break;
1105 }
1106 }
1107
1108 fakez=(new_z>0 ? new_z : zfix(0));
1109 }
1110
1111 64402 void HeroClass::setFall(zfix new_fall)
1112 {
1113 64402 fall=new_fall;
1114 64402 justmoved = 2;
1115 64402 jumping=-1;
1116 64402 }
1117 void HeroClass::setFakeFall(zfix new_fall)
1118 {
1119 fakefall=new_fall;
1120 jumping=-1;
1121 }
1122 void HeroClass::setClimbCoverX(int32_t new_x)
1123 {
1124 climb_cover_x=new_x;
1125 }
1126 void HeroClass::setClimbCoverY(int32_t new_y)
1127 {
1128 climb_cover_y=new_y;
1129 }
1130 72735 int32_t HeroClass::getLStep()
1131 {
1132 72735 return lstep;
1133 }
1134 3758 int32_t HeroClass::getCharging()
1135 {
1136 3758 return charging;
1137 }
1138 63082 bool HeroClass::isCharged()
1139 {
1140 63082 return spins>0;
1141 }
1142 int32_t HeroClass::getAttackClk()
1143 {
1144 return attackclk;
1145 }
1146 void HeroClass::setAttackClk(int32_t new_clk)
1147 {
1148 attackclk=new_clk;
1149 }
1150 void HeroClass::setCharging(int32_t new_charging)
1151 {
1152 charging=new_charging;
1153 }
1154 3378662423 int32_t HeroClass::getSwordClk()
1155 {
1156 3378662423 return swordclk;
1157 }
1158 3336328137 int32_t HeroClass::getItemClk()
1159 {
1160 3336328137 return itemclk;
1161 }
1162 6 void HeroClass::setSwordClk(int32_t newclk)
1163 {
1164 6 swordclk=newclk;
1165 6 verifyAWpn();
1166 6 }
1167 5163 void HeroClass::setItemClk(int32_t newclk)
1168 {
1169 5163 itemclk=newclk;
1170 5163 }
1171 // TODO remove, no longer needed.
1172 811577 zfix HeroClass::getModifiedX()
1173 {
1174 811577 zfix tempx=x;
1175 811577 return tempx;
1176 }
1177
1178 811577 zfix HeroClass::getModifiedY()
1179 {
1180 811577 zfix tempy=y;
1181 811577 return tempy;
1182 }
1183
1184 18324 int32_t HeroClass::getDir()
1185 {
1186 18324 return dir;
1187 }
1188 93219 void HeroClass::setDir(int32_t newdir)
1189 {
1190 93219 dir=newdir;
1191 93219 reset_hookshot();
1192 93219 }
1193 int32_t HeroClass::getHitDir()
1194 {
1195 return hitdir;
1196 }
1197 void HeroClass::setHitDir(int32_t newdir)
1198 {
1199 hitdir = newdir;
1200 }
1201 int32_t HeroClass::getClk()
1202 {
1203 return clk;
1204 }
1205 int32_t HeroClass::getPushing()
1206 {
1207 return pushing;
1208 }
1209 9459 void HeroClass::Catch()
1210 {
1211
5/6
✓ Branch 0 taken 9459 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7267 times.
✓ Branch 3 taken 2192 times.
✓ Branch 4 taken 4155 times.
✓ Branch 5 taken 3112 times.
9459 if(!inwallm && (action==none || action==walking))
1212 {
1213 6347 SetAttack();
1214 6347 attackclk=0;
1215 6347 attack=wCatching;
1216 6347 }
1217 9459 }
1218
1219 6141912 bool HeroClass::getClock()
1220 {
1221 6141912 return superman;
1222 }
1223 807 void HeroClass::setClock(bool state)
1224 {
1225 807 superman=state;
1226 807 }
1227 47450128 int32_t HeroClass::getAction() // Used by ZScript
1228 {
1229
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 47442496 times.
47450128 if(spins > 0)
1230 7632 return isspinning;
1231
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 47425207 times.
47442496 else if(charging > 0)
1232 17289 return ischarging;
1233
2/2
✓ Branch 0 taken 47383565 times.
✓ Branch 1 taken 41642 times.
47425207 else if(diveclk > 0)
1234 41642 return isdiving;
1235 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1236
1237 47383565 return action;
1238 47450128 }
1239
1240 52058922 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1241 {
1242
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 52058074 times.
52058922 if(spins > 0)
1243 848 return isspinning;
1244
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 52056153 times.
52058074 else if(charging > 0)
1245 1921 return ischarging;
1246
2/2
✓ Branch 0 taken 51867253 times.
✓ Branch 1 taken 188900 times.
52056153 else if(diveclk > 0)
1247 188900 return isdiving;
1248 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1249
1250 51867253 return -1;
1251 52058922 }
1252
1253 404 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1254 {
1255
4/8
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 404 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 404 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 404 times.
808 if(new_action==dying || new_action==won || new_action==scrolling ||
1256
3/6
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 404 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 404 times.
✗ Branch 5 not taken.
404 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1257 404 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1258 return; // Can't use these actions.
1259
1260
3/6
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 205 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
404 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1261 return;
1262
1263
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(new_action==rafting)
1264 {
1265 if(get_qr(qr_DISALLOW_SETTING_RAFTING)) return;
1266 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1267 return;
1268 }
1269
1270
1271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
404 if(magicitem>-1 && itemsbuf[magicitem].family==itype_divineescape)
1272 {
1273 // Using Divine Escape
1274 if(magiccastclk<96)
1275 {
1276 // Not cast yet; cancel it
1277 magicitem=-1;
1278 magiccastclk=0;
1279 }
1280 else
1281 // Already activated; don't do anything
1282 return;
1283 }
1284
1285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(action==inwind) // Remove from whirlwind
1286 {
1287 xofs=0;
1288 whirlwind=0;
1289 lstep=0;
1290 if ( dontdraw < 2 ) { dontdraw=0; }
1291 }
1292
2/4
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 404 times.
404 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1293 {
1294 sprite* wind=0;
1295 bool foundWind=false;
1296 for(int32_t i=0; i<Ewpns.Count(); i++)
1297 {
1298 wind=Ewpns.spr(i);
1299 if(wind->id==ewWind && wind->misc==999)
1300 {
1301 foundWind=true;
1302 break;
1303 }
1304 }
1305
1306 if(foundWind)
1307 {
1308 xofs=0;
1309 if ( dontdraw < 2 ) { dontdraw=false; }
1310 wind->misc=-1;
1311 x=wind->x;
1312 y=wind->y;
1313 }
1314 }
1315
1316 //Unless compat rule is on, reset hopping clocks when writing action!
1317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
404 if(action == hopping && !get_qr(qr_NO_OVERWRITING_HOPPING))
1318 {
1319 hopclk = 0;
1320 hopdir = -1;
1321 }
1322
1323
3/4
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 279 times.
404 if(new_action != attacking && new_action != sideswimattacking)
1324 {
1325 279 attackclk=0;
1326
1327
1/2
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
279 if(attack==wHookshot)
1328 reset_hookshot();
1329 279 }
1330
2/4
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 404 times.
404 if(new_action != isspinning && new_action != sideswimisspinning)
1331 {
1332 404 charging = 0;
1333 404 spins = 0;
1334 404 }
1335
1336
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
404 if(action == falling && new_action != falling)
1337 {
1338 fallclk = 0; //Stop falling;
1339 }
1340
1341
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
404 if (action == rafting && new_action != rafting)
1342 {
1343 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1344 raftwarpy = y;
1345 }
1346
1347
3/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 278 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
404 switch(new_action)
1348 {
1349 case isspinning:
1350 case sideswimisspinning:
1351 if(attack==wSword)
1352 {
1353 attackclk = SWORDCHARGEFRAME+1;
1354 charging = 0;
1355
1356 if(spins==0)
1357 spins = 5;
1358 }
1359 return;
1360
1361 case isdiving:
1362 if(action==swimming && diveclk==0)
1363 {
1364 int32_t flippers_id = current_item_id(itype_flippers);
1365 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1366 }
1367 return;
1368
1369 case drowning:
1370 case sidedrowning:
1371 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1372 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1373 if(!drownclk)
1374 Drown();
1375
1376 break;
1377
1378 case lavadrowning:
1379 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1380 if(!drownclk)
1381 Drown(1);
1382
1383 break;
1384
1385 case falling:
1386 if(!fallclk)
1387 {
1388 //If there is a pit under Hero, use it's combo.
1389 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1390 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1391 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1392 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1393 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1394 //Else, use a null value; triggers default pit values
1395 else fallCombo = 0;
1396 fallclk = PITFALL_FALL_FRAMES;
1397 }
1398 break;
1399
1400 case gothit:
1401 case swimhit:
1402 case sideswimhit:
1403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!hclk)
1404 1 hclk=48;
1405
1406 1 break;
1407
1408 case landhold1:
1409 case landhold2:
1410 case waterhold1:
1411 case waterhold2:
1412 case sidewaterhold1:
1413 case sidewaterhold2:
1414 if(!holdclk)
1415 holdclk=130;
1416
1417 attack=none;
1418 break;
1419
1420 case attacking:
1421 case sideswimattacking:
1422 125 attack=none;
1423 125 break;
1424
1425 default:
1426 278 break;
1427 }
1428
1429 404 action=new_action; FFCore.setHeroAction(new_action);
1430 404 }
1431
1432 void HeroClass::setHeldItem(int32_t newitem)
1433 {
1434 holditem=newitem;
1435 }
1436 17 int32_t HeroClass::getHeldItem()
1437 {
1438 17 return holditem;
1439 }
1440 9544936 bool HeroClass::isDiving()
1441 {
1442 9544936 int32_t flippers_id = current_item_id(itype_flippers);
1443
2/2
✓ Branch 0 taken 6882247 times.
✓ Branch 1 taken 2662689 times.
9544936 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1444 }
1445 15405570 bool HeroClass::isSwimming()
1446 {
1447
4/6
✓ Branch 0 taken 15259871 times.
✓ Branch 1 taken 145699 times.
✓ Branch 2 taken 15259871 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15259871 times.
✗ Branch 5 not taken.
30665441 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1448
4/4
✓ Branch 0 taken 15258441 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 1328 times.
✓ Branch 3 taken 15257113 times.
15259871 (action==waterhold1)||(action==waterhold2)||
1449 15257113 (hopclk==0xFF));
1450 }
1451
1452 1453 void HeroClass::setDontDraw(byte new_dontdraw)
1453 {
1454 1453 dontdraw=new_dontdraw;
1455 1453 }
1456
1457 1111980 byte HeroClass::getDontDraw()
1458 {
1459 1111980 return dontdraw;
1460 }
1461
1462 void HeroClass::setHClk(int32_t newhclk)
1463 {
1464 hclk=newhclk;
1465 }
1466
1467 87306 int32_t HeroClass::getHClk()
1468 {
1469 87306 return hclk;
1470 }
1471
1472 5010169 int32_t HeroClass::getSpecialCave()
1473 {
1474 5010169 return specialcave; // used only by maps.cpp
1475 }
1476
1477 529 void HeroClass::init()
1478 {
1479 529 usecounts.clear();
1480 529 scale = 0;
1481 529 rotation = 0;
1482 529 do_animation = 1;
1483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(lift_wpn)
1484 {
1485 delete lift_wpn;
1486 lift_wpn = nullptr;
1487 }
1488 529 liftclk = 0;
1489 529 tliftclk = 0;
1490 529 liftheight = 0;
1491 529 liftflags = 0;
1492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1493 529 hookshot_used=false;
1494 529 justmoved = 0;
1495 529 hookshot_frozen=false;
1496 529 onpassivedmg=false;
1497 529 dir = up;
1498 529 damageovertimeclk = 0;
1499 529 newconveyorclk = 0;
1500 529 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1501
2/2
✓ Branch 0 taken 3703 times.
✓ Branch 1 taken 529 times.
4232 for(auto q = 0; q < 7; ++q)
1502 3703 hooked_undercombos[q] = -1;
1503 529 shiftdir = -1;
1504 529 sideswimdir = right;
1505 529 holddir = -1;
1506 529 landswim = 0;
1507 529 sdir = up;
1508 529 ilswim=true;
1509 529 walkable=false;
1510 529 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1511 529 warp_sound = 0;
1512 529 subscr_speed = zinit.subscrSpeed;
1513 529 steprate = zinit.heroStep;
1514 529 is_warping = false;
1515 529 coyotetime = 0;
1516
1517 529 hammer_swim_up_offset = hammeroffsets[0];
1518 529 hammer_swim_down_offset = hammeroffsets[1];
1519 529 hammer_swim_left_offset = hammeroffsets[2];
1520 529 hammer_swim_right_offset = hammeroffsets[3];
1521
1522 529 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1523
1524
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 348 times.
529 if(get_qr(qr_NOARRIVALPOINT))
1525 {
1526 181 x=tmpscr->warpreturnx[0];
1527 181 y=tmpscr->warpreturny[0];
1528 181 }
1529 else
1530 {
1531 348 x=tmpscr->warparrivalx;
1532 348 y=tmpscr->warparrivaly;
1533 }
1534
1535 529 z=fakez=fall=fakefall=0;
1536 529 hzsz = 12; // So that flying peahats can still hit him.
1537
1538
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 376 times.
529 if(x==0) dir=right;
1539
1540
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 527 times.
529 if(x==240) dir=left;
1541
1542
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 369 times.
529 if(y==0) dir=down;
1543
1544
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 412 times.
529 if(y==160) dir=up;
1545
1546 529 lstep=0;
1547 529 skipstep=0;
1548 529 autostep=false;
1549 529 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1550 529 attack=wNone;
1551 529 attackid=-1;
1552 529 action=none; FFCore.setHeroAction(none); tempaction=none;
1553 529 xofs=0;
1554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1555 529 cs=6;
1556 529 pushing=fairyclk=0;
1557 529 id=0;
1558 529 inlikelike=0;
1559 529 superman=inwallm=false;
1560 529 scriptcoldet=1;
1561 529 blowcnt=whirlwind=specialcave=0;
1562 529 hopclk=diveclk=fallclk=0;
1563 529 fallCombo = 0;
1564 529 pit_pulldir = -1;
1565 529 hopdir=-1;
1566 529 conveyor_flags=0;
1567 529 drunkclk=0;
1568 529 lstunclock = 0;
1569 529 is_conveyor_stunned=0;
1570 529 convey_forcex=convey_forcey=0;
1571 529 drawstyle=3;
1572 529 ffwarp = false;
1573 529 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1574 529 stepnext=stepsecret=-1;
1575 529 ffpit = false;
1576 529 respawn_x=x;
1577 529 respawn_y=y;
1578 529 respawn_dmap=currdmap;
1579 529 respawn_scr=currscr;
1580 529 falling_oldy = y;
1581 529 magiccastclk=0;
1582 529 magicitem = div_prot_item = -1;
1583 529 last_lens_id = 0; //Should be -1 (-Z)
1584 529 last_savepoint_id = 0;
1585 529 misc_internal_hero_flags = 0;
1586 529 last_cane_of_byrna_item_id = -1;
1587 529 on_sideview_ladder = false;
1588 529 switchblock_z = 0;
1589 529 switchblock_offset = false;
1590 529 extra_jump_count = 0;
1591 529 hoverflags = 0;
1592 529 lbunnyclock = 0;
1593
1594
2/2
✓ Branch 0 taken 16928 times.
✓ Branch 1 taken 529 times.
17457 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1595
1596 529 setBigHitbox(get_qr(qr_LTTPCOLLISION));
1597 529 diagonalMovement=(get_qr(qr_LTTPWALK));
1598
1599 529 shield_active = false;
1600 529 shield_forcedir = -1;
1601 529 active_shield_id = -1;
1602 529 conv_forcedir = -1;
1603
1604 //2.6
1605 529 preventsubscreenfalling = false; //-Z
1606 529 walkspeed = 0; //not used, yet. -Z
1607
2/2
✓ Branch 0 taken 8993 times.
✓ Branch 1 taken 529 times.
9522 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1608
2/2
✓ Branch 0 taken 8993 times.
✓ Branch 1 taken 529 times.
9522 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1609
2/2
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 529 times.
77763 for ( int32_t q = 0; q < wMax; q++ )
1610 {
1611 77234 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1612 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1613 77234 }
1614 //Run script!
1615
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 487 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 28 times.
529 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1616 {
1617 14 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_INIT);
1618 14 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_INIT);
1619 14 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1620 14 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1621 //are properly set by the engine.
1622 14 }
1623 529 FFCore.nostepforward = 0;
1624
1625
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 221 times.
529 if (replay_version_check(12))
1626 221 z3step = 2;
1627 529 }
1628
1629 8273906 void HeroClass::draw_under(BITMAP* dest)
1630 {
1631 8273906 int32_t c_raft=current_item_id(itype_raft);
1632 8273906 int32_t c_ladder=current_item_id(itype_ladder);
1633
1634
3/4
✓ Branch 0 taken 86410 times.
✓ Branch 1 taken 8187496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86410 times.
8273906 if(action==rafting && c_raft >-1)
1635 {
1636
4/4
✓ Branch 0 taken 63121 times.
✓ Branch 1 taken 23289 times.
✓ Branch 2 taken 45124 times.
✓ Branch 3 taken 41286 times.
86410 if(((dir==left) || (dir==right)) && (get_qr(qr_RLFIX)))
1637 {
1638 82572 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1639 41286 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1640 41286 }
1641 else
1642 {
1643 90248 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1644 45124 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1645 }
1646 86410 }
1647
1648
3/4
✓ Branch 0 taken 101749 times.
✓ Branch 1 taken 8172157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101749 times.
8273906 if(ladderx+laddery && c_ladder >-1)
1649 {
1650
4/4
✓ Branch 0 taken 46470 times.
✓ Branch 1 taken 55279 times.
✓ Branch 2 taken 28103 times.
✓ Branch 3 taken 18367 times.
101749 if((ladderdir>=left) && (get_qr(qr_RLFIX)))
1651 {
1652 56206 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1653 28103 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1654 28103 }
1655 else
1656 {
1657 147292 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1658 73646 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1659 }
1660 101749 }
1661 8273906 }
1662
1663 3997 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1664 {
1665 3997 int32_t tempy=yofs;
1666 3997 yofs+=8;
1667 3997 shadowtile = wpnsbuf[spr_shadow].tile;
1668 3997 sprite::drawshadow(dest,translucent);
1669 3997 yofs=tempy;
1670 3997 }
1671
1672 // The Stone of Agony reacts to these flags.
1673 487612 bool HeroClass::agonyflag(int32_t flag)
1674 {
1675
2/2
✓ Branch 0 taken 487580 times.
✓ Branch 1 taken 32 times.
487612 switch(flag)
1676 {
1677 case mfWHISTLE:
1678 case mfANYFIRE:
1679 case mfARROW:
1680 case mfBOMB:
1681 case mfSBOMB:
1682 case mfBRANG:
1683 case mfMBRANG:
1684 case mfFBRANG:
1685 case mfSARROW:
1686 case mfGARROW:
1687 case mfSTRONGFIRE:
1688 case mfMAGICFIRE:
1689 case mfDIVINEFIRE:
1690 case mfWANDMAGIC:
1691 case mfREFMAGIC:
1692 case mfREFFIREBALL:
1693 case mfSWORD:
1694 case mfWSWORD:
1695 case mfMSWORD:
1696 case mfXSWORD:
1697 case mfSWORDBEAM:
1698 case mfWSWORDBEAM:
1699 case mfMSWORDBEAM:
1700 case mfXSWORDBEAM:
1701 case mfHOOKSHOT:
1702 case mfWAND:
1703 case mfHAMMER:
1704 case mfSTRIKE:
1705 32 return true;
1706 }
1707
1708 487580 return false;
1709 487612 }
1710
1711
1712 // Find the attack power of the current melee weapon.
1713 // The Whimsical Ring is applied on a target-by-target basis.
1714 504717 int32_t HeroClass::weaponattackpower(int32_t itid)
1715 {
1716
1/2
✓ Branch 0 taken 504717 times.
✗ Branch 1 not taken.
504717 if(itid < 0)
1717 {
1718 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1719 : attack==wWand ? itype_wand
1720 : attack==wHammer ? itype_hammer
1721 : itype_sword);
1722 }
1723
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 504697 times.
504717 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1724
1725 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1726
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 504143 times.
504717 if(spins > 0)
1727 {
1728 574 int scr = currentscroll;
1729
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(scr < 0)
1730 {
1731 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1732 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1733 ? itype_spinscroll2 : itype_spinscroll);
1734 }
1735 574 power *= itemsbuf[scr].power;
1736 574 }
1737 504143 else currentscroll = -1;
1738 504717 return power;
1739 }
1740
1741 #define NET_CLK_TOTAL 24
1742 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1743 // Must only be called once per frame!
1744 void HeroClass::positionNet(weapon *w, int32_t itemid)
1745 {
1746 itemid = vbound(itemid, 0, MAXITEMS-1);
1747 int32_t t = w->o_tile,
1748 wx = 1, wy = 1;
1749
1750 //Invert positioning clock if right-handed animation
1751 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1752 if(clock >= NET_CLK_TOTAL)
1753 w->dead = 0;
1754 int32_t tiledir = dir;
1755 switch(dir)
1756 {
1757 case up:
1758 {
1759 if(clock < NET_DIR_INC) tiledir = l_up;
1760 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1761 break;
1762 }
1763 case down:
1764 {
1765 if(clock < NET_DIR_INC) tiledir = r_down;
1766 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1767 break;
1768 }
1769 case left:
1770 {
1771 if(clock < NET_DIR_INC) tiledir = l_down;
1772 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1773 break;
1774 }
1775 case right:
1776 {
1777 if(clock < NET_DIR_INC) tiledir = r_up;
1778 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1779 break;
1780 }
1781 }
1782 int32_t offs = 0;
1783 if(tiledir > right)
1784 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1785 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1786 //One of 8 positions
1787 switch(tiledir)
1788 {
1789 case up:
1790 {
1791 wx = 6*offs;
1792 wy = -14;
1793 break;
1794 }
1795 case r_up:
1796 {
1797 wx = (offs ? 10 : 14);
1798 wy = (offs ? -12 : -10);
1799 break;
1800 }
1801 case right:
1802 {
1803 wx = 14;
1804 wy = 6*offs;
1805 break;
1806 }
1807 case r_down:
1808 {
1809 wx = (offs ? 14 : 10);
1810 wy = (offs ? 10 : 12);
1811 break;
1812 }
1813 case down:
1814 {
1815 wx = -6*offs;
1816 wy = 14;
1817 break;
1818 }
1819 case l_down:
1820 {
1821 wx = (offs ? -10 : -14);
1822 wy = (offs ? 12 : 10);
1823 break;
1824 }
1825 case left:
1826 {
1827 wx = -14;
1828 wy = -6*offs;
1829 break;
1830 }
1831 case l_up:
1832 {
1833 wx = (offs ? -14 : -10);
1834 wy = (offs ? -10 : -12);
1835 break;
1836 }
1837 }
1838
1839 w->x = x+wx;
1840 w->y = y+wy-(54-(yofs))-fakez;
1841 w->z = (z+zofs);
1842 w->fakez = fakez;
1843 w->tile = t+tiledir;
1844 w->power = 0;
1845 w->dir = dir;
1846 w->doAutoRotate(true);
1847 }
1848 446210 void HeroClass::positionSword(weapon *w, int32_t itemid)
1849 {
1850 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1851 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1852 446210 itemid=vbound(itemid, 0, MAXITEMS-1);
1853 // Place a sword weapon at the right spot.
1854 446210 int32_t wy=1;
1855 446210 int32_t wx=1;
1856 446210 int32_t f=0,t,cs2;
1857
1858 446210 t = w->o_tile;
1859 446210 cs2 = w->o_cset;
1860 446210 slashxofs=0;
1861 446210 slashyofs=0;
1862
1863
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 101969 times.
✓ Branch 2 taken 96212 times.
✓ Branch 3 taken 122792 times.
✓ Branch 4 taken 125237 times.
446210 switch(dir)
1864 {
1865 case up:
1866 101969 wx=-1;
1867 101969 wy=-12;
1868
1869
7/8
✓ Branch 0 taken 12339 times.
✓ Branch 1 taken 89630 times.
✓ Branch 2 taken 11286 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 10876 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10876 times.
101969 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1870 {
1871
2/2
✓ Branch 0 taken 7054 times.
✓ Branch 1 taken 3822 times.
10876 if(attackclk>10) //extended stab
1872 {
1873 3822 slashyofs-=3;
1874 3822 wy-=2;
1875 3822 }
1876
1877
2/2
✓ Branch 0 taken 9925 times.
✓ Branch 1 taken 951 times.
10876 if(attackclk>=14) //retracting stab
1878 {
1879 951 slashyofs+=3;
1880 951 wy+=2;
1881 951 }
1882 10876 }
1883 else
1884 {
1885
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 90807 times.
91093 if(attackclk==SWORDCHARGEFRAME)
1886 {
1887 286 wy+=4;
1888 286 }
1889
2/2
✓ Branch 0 taken 8823 times.
✓ Branch 1 taken 81984 times.
90807 else if(attackclk==13)
1890 {
1891 8823 wy+=4;
1892 8823 }
1893
2/2
✓ Branch 0 taken 73259 times.
✓ Branch 1 taken 8725 times.
81984 else if(attackclk==14)
1894 {
1895 8725 wy+=8;
1896 8725 }
1897 }
1898
1899 101969 break;
1900
1901 case down:
1902 96212 f=get_qr(qr_SWORDWANDFLIPFIX)?3:2;
1903 96212 wy=11;
1904
1905
7/8
✓ Branch 0 taken 14419 times.
✓ Branch 1 taken 81793 times.
✓ Branch 2 taken 13662 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 13302 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13302 times.
96212 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1906 {
1907
2/2
✓ Branch 0 taken 8569 times.
✓ Branch 1 taken 4733 times.
13302 if(attackclk>10) //extended stab
1908 {
1909 4733 slashyofs+=3;
1910 4733 wy+=2;
1911 4733 }
1912
1913
2/2
✓ Branch 0 taken 12130 times.
✓ Branch 1 taken 1172 times.
13302 if(attackclk>=14) //retracting stab
1914 {
1915 1172 slashyofs-=3;
1916 1172 wy-=2;
1917 1172 }
1918 13302 }
1919 else
1920 {
1921
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 82310 times.
82910 if(attackclk==SWORDCHARGEFRAME)
1922 {
1923 600 wy-=2;
1924 600 }
1925
2/2
✓ Branch 0 taken 8099 times.
✓ Branch 1 taken 74211 times.
82310 else if(attackclk==13)
1926 {
1927 8099 wy-=4;
1928 8099 }
1929
2/2
✓ Branch 0 taken 66140 times.
✓ Branch 1 taken 8071 times.
74211 else if(attackclk==14)
1930 {
1931 8071 wy-=8;
1932 8071 }
1933 }
1934
1935 96212 break;
1936
1937 case left:
1938 122792 f=1;
1939 122792 wx=-11;
1940 122792 ++t;
1941
1942
7/8
✓ Branch 0 taken 20869 times.
✓ Branch 1 taken 101923 times.
✓ Branch 2 taken 18551 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 17699 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 17699 times.
122792 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1943 {
1944
2/2
✓ Branch 0 taken 11362 times.
✓ Branch 1 taken 6337 times.
17699 if(attackclk>10) //extended stab
1945 {
1946 6337 slashxofs-=4;
1947 6337 wx-=7;
1948 6337 }
1949
1950
2/2
✓ Branch 0 taken 16126 times.
✓ Branch 1 taken 1573 times.
17699 if(attackclk>=14) //retracting stab
1951 {
1952 1573 slashxofs+=3;
1953 1573 wx+=7;
1954 1573 }
1955 17699 }
1956 else
1957 {
1958
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 104890 times.
105093 if(attackclk==SWORDCHARGEFRAME)
1959 {
1960 203 wx+=2;
1961 203 }
1962
2/2
✓ Branch 0 taken 10343 times.
✓ Branch 1 taken 94547 times.
104890 else if(attackclk==13)
1963 {
1964 10343 wx+=4;
1965 10343 }
1966
2/2
✓ Branch 0 taken 84240 times.
✓ Branch 1 taken 10307 times.
94547 else if(attackclk==14)
1967 {
1968 10307 wx+=8;
1969 10307 }
1970 }
1971
1972 122792 break;
1973
1974 case right:
1975 125237 wx=11;
1976 125237 ++t;
1977
1978
7/8
✓ Branch 0 taken 21423 times.
✓ Branch 1 taken 103814 times.
✓ Branch 2 taken 19546 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 17712 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 17712 times.
✗ Branch 7 not taken.
125237 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1979 {
1980
2/2
✓ Branch 0 taken 11286 times.
✓ Branch 1 taken 6426 times.
17712 if(attackclk>10) //extended stab
1981 {
1982 6426 slashxofs+=4;
1983 6426 wx+=7;
1984 6426 }
1985
1986
2/2
✓ Branch 0 taken 16102 times.
✓ Branch 1 taken 1610 times.
17712 if(attackclk>=14) //retracting stab
1987 {
1988 1610 slashxofs-=3;
1989 1610 wx-=7;
1990 1610 }
1991 17712 }
1992 else
1993 {
1994
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 106930 times.
107525 if(attackclk==SWORDCHARGEFRAME)
1995 {
1996 595 wx-=2;
1997 595 }
1998
2/2
✓ Branch 0 taken 10521 times.
✓ Branch 1 taken 96409 times.
106930 else if(attackclk==13)
1999 {
2000 10521 wx-=4;
2001 10521 }
2002
2/2
✓ Branch 0 taken 85915 times.
✓ Branch 1 taken 10494 times.
96409 else if(attackclk==14)
2003 {
2004 10494 wx-=8;
2005 10494 }
2006 }
2007
2008 125237 break;
2009 }
2010
2011
6/6
✓ Branch 0 taken 69050 times.
✓ Branch 1 taken 377160 times.
✓ Branch 2 taken 59609 times.
✓ Branch 3 taken 9441 times.
✓ Branch 4 taken 21326 times.
✓ Branch 5 taken 38283 times.
446210 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
2012 {
2013 38283 int32_t wpn2=itemsbuf[itemid].wpn2;
2014 38283 wpn2=vbound(wpn2, 0, MAXWPNS);
2015
2016 //slashing tiles
2017
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7054 times.
✓ Branch 2 taken 8575 times.
✓ Branch 3 taken 11362 times.
✓ Branch 4 taken 11292 times.
38283 switch(dir)
2018 {
2019 case up:
2020 7054 wx=15;
2021 7054 wy=-3;
2022 7054 ++t;
2023 7054 f=0; //starts pointing right
2024
2025
2/2
✓ Branch 0 taken 3109 times.
✓ Branch 1 taken 3945 times.
7054 if(attackclk>=7)
2026 {
2027 3945 wy-=9;
2028 3945 wx-=3;
2029 3945 t = wpnsbuf[wpn2].tile;
2030 3945 cs2 = wpnsbuf[wpn2].csets&15;
2031 3945 f=0;
2032 3945 }
2033
2034 7054 break;
2035
2036 case down:
2037 8575 wx=-13;
2038 8575 wy=-1;
2039 8575 ++t;
2040 8575 f=1; //starts pointing left
2041
2042
2/2
✓ Branch 0 taken 3718 times.
✓ Branch 1 taken 4857 times.
8575 if(attackclk>=7)
2043 {
2044 4857 wy+=15;
2045 4857 wx+=2;
2046 4857 t = wpnsbuf[wpn2].tile;
2047 4857 cs2 = wpnsbuf[wpn2].csets&15;
2048 4857 ++t;
2049 4857 f=0;
2050 4857 }
2051
2052 8575 break;
2053
2054 case left:
2055 11362 wx=3;
2056 11362 wy=-15;
2057 11362 --t;
2058 11362 f=0; //starts pointing up
2059
2060
2/2
✓ Branch 0 taken 4905 times.
✓ Branch 1 taken 6457 times.
11362 if(attackclk>=7)
2061 {
2062 6457 wx-=15;
2063 6457 wy+=3;
2064 6457 slashxofs-=1;
2065 6457 t = wpnsbuf[wpn2].tile;
2066 6457 cs2 = wpnsbuf[wpn2].csets&15;
2067 6457 t+=2;
2068 6457 f=0;
2069 6457 }
2070
2071 11362 break;
2072
2073 case right:
2074 11292 --t;
2075
2076
2/4
✓ Branch 0 taken 11292 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11292 times.
11292 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2077 {
2078 wx=1;
2079 wy=13;
2080 f=2;
2081 }
2082 else
2083 {
2084 11292 wx=3;
2085 11292 wy=-15;
2086 11292 f=0;
2087 }
2088
2089
2/2
✓ Branch 0 taken 4888 times.
✓ Branch 1 taken 6404 times.
11292 if(attackclk>=7)
2090 {
2091 6404 wx+=15;
2092 6404 slashxofs+=1;
2093 6404 t = wpnsbuf[wpn2].tile;
2094 6404 cs2 = wpnsbuf[wpn2].csets&15;
2095
2096
2/4
✓ Branch 0 taken 6404 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6404 times.
6404 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2097 {
2098 wx-=1;
2099 wy-=2;
2100 }
2101 else
2102 {
2103 6404 t+=3;
2104 6404 f=0;
2105 6404 wy+=3;
2106 }
2107 6404 }
2108
2109 11292 break;
2110 }
2111 38283 }
2112
2113 446210 int32_t itemid2 = current_item_id(itype_chargering);
2114
2115
4/4
✓ Branch 0 taken 21741 times.
✓ Branch 1 taken 424469 times.
✓ Branch 2 taken 445678 times.
✓ Branch 3 taken 532 times.
446210 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2116 {
2117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2118 532 }
2119
2120 /*if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2121 {
2122 wy+=2;
2123 }*/
2124 446210 w->x = x+wx;
2125 446210 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2126 446210 w->z = (z+zofs);
2127 446210 w->tile = t;
2128 446210 w->flip = f;
2129 446210 w->power = weaponattackpower(itemid);
2130 446210 w->dir = dir;
2131 446210 w->doAutoRotate(true);
2132 446210 }
2133
2134 int HeroClass::getHammerState() const
2135 {
2136 if(attack == wHammer)
2137 {
2138 if(attackclk >= 15)
2139 return 3;
2140 if(attackclk >= 13)
2141 return 2;
2142 return 1;
2143 }
2144 return 0;
2145 }
2146
2147 8323146 void HeroClass::draw(BITMAP* dest)
2148 {
2149 /*{
2150 char buf[36];
2151 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2152 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2153 }*/
2154 8323146 int32_t oxofs = xofs, oyofs = yofs;
2155 8323146 bool shieldModify = false;
2156
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 8292902 times.
8323146 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2157
2158 {
2159
2/2
✓ Branch 0 taken 5580 times.
✓ Branch 1 taken 8317566 times.
8323146 if(action==dying)
2160 {
2161
2/2
✓ Branch 0 taken 4334 times.
✓ Branch 1 taken 1246 times.
5580 if(!invisible)
2162 {
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1246 times.
1246 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2164 1246 sprite::draw(dest);
2165 1246 }
2166 5580 goto herodraw_end;
2167 }
2168
2169 8317566 bool useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2170
2171
2172
2/2
✓ Branch 0 taken 91720 times.
✓ Branch 1 taken 8225846 times.
8317566 if(!invisible)
2173
6/6
✓ Branch 0 taken 6293620 times.
✓ Branch 1 taken 1932226 times.
✓ Branch 2 taken 3995272 times.
✓ Branch 3 taken 2298348 times.
✓ Branch 4 taken 170808 times.
✓ Branch 5 taken 3824464 times.
8225846 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2174
2175 // Stone of Agony
2176 8317566 bool agony=false;
2177 8317566 int32_t agonyid = current_item_id(itype_agony);
2178
2179
2/2
✓ Branch 0 taken 91720 times.
✓ Branch 1 taken 8225846 times.
8317566 if(!invisible)
2180 {
2181
2/2
✓ Branch 0 taken 243814 times.
✓ Branch 1 taken 7982032 times.
8225846 if(agonyid>-1)
2182 {
2183 243814 int32_t power=itemsbuf[agonyid].power;
2184 243814 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2185 243814 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2186 243814 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2187 243814 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2188
2189
2/2
✓ Branch 0 taken 243814 times.
✓ Branch 1 taken 243814 times.
487628 for(int32_t x=left; x<right; x+=16)
2190 {
2191
2/2
✓ Branch 0 taken 243782 times.
✓ Branch 1 taken 243814 times.
487596 for(int32_t y=top; y<bottom; y+=16)
2192 {
2193
4/4
✓ Branch 0 taken 243798 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 243782 times.
243814 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2194 {
2195 32 agony=true;
2196 32 x=right; // Break out of outer loop
2197 32 break;
2198 }
2199 243782 }
2200 243814 }
2201 243814 }
2202
2203 8225846 cs = 6;
2204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8225846 times.
8225846 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2205
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 6924784 times.
8225846 if(!get_qr(qr_HEROFLICKER))
2206 {
2207
3/4
✓ Branch 0 taken 102737 times.
✓ Branch 1 taken 6822047 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102737 times.
6924784 if(superman && getCanFlicker())
2208 {
2209 102737 cs += (((~frame)>>1)&3);
2210 102737 }
2211
4/6
✓ Branch 0 taken 271855 times.
✓ Branch 1 taken 6550192 times.
✓ Branch 2 taken 271855 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 271855 times.
6822047 else if(hclk&&(DivineProtectionShieldClk<=0) && getCanFlicker())
2212 {
2213 271855 cs += ((hclk>>1)&3);
2214 271855 }
2215 6924784 }
2216 8225846 }
2217
2218
5/6
✓ Branch 0 taken 7486997 times.
✓ Branch 1 taken 830569 times.
✓ Branch 2 taken 7480579 times.
✓ Branch 3 taken 6418 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7480579 times.
8317566 if(attackclk || (action==attacking||action==sideswimattacking))
2219 {
2220 /* Spaghetti code constants!
2221 * - Hero.attack contains a weapon type...
2222 * - which must be converted to an itype...
2223 * - which must be converted to an item ID...
2224 * - which is used to acquire a wpn ID! Aack!
2225 */
2226
8/8
✓ Branch 0 taken 13328 times.
✓ Branch 1 taken 823659 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 823631 times.
✓ Branch 4 taken 21498 times.
✓ Branch 5 taken 802133 times.
✓ Branch 6 taken 22079 times.
✓ Branch 7 taken 780054 times.
836987 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2227
4/4
✓ Branch 0 taken 29501 times.
✓ Branch 1 taken 807486 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28594 times.
836987 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2228 836987 itemid=vbound(itemid, 0, MAXITEMS-1);
2229 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2230
7/8
✓ Branch 0 taken 270957 times.
✓ Branch 1 taken 566030 times.
✓ Branch 2 taken 270957 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175081 times.
✓ Branch 5 taken 95876 times.
✓ Branch 6 taken 23622 times.
✓ Branch 7 taken 151459 times.
836987 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2231 {
2232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 589652 times.
589652 if(attack == wBugNet)
2233 {
2234 weapon *w=NULL;
2235 bool found = false;
2236 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2237 {
2238 w = (weapon*)Lwpns.spr(q);
2239 if(w->id == wBugNet)
2240 {
2241 found = true;
2242 break;
2243 }
2244 }
2245 if(!found)
2246 {
2247 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2248
2249 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2250 }
2251 positionNet(w, itemid);
2252 }
2253
8/8
✓ Branch 0 taken 141133 times.
✓ Branch 1 taken 448519 times.
✓ Branch 2 taken 125779 times.
✓ Branch 3 taken 15354 times.
✓ Branch 4 taken 116583 times.
✓ Branch 5 taken 9196 times.
✓ Branch 6 taken 125759 times.
✓ Branch 7 taken 463893 times.
589652 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2254 {
2255 // Create a sword weapon at the right spot.
2256 463893 weapon *w=NULL;
2257 463893 bool found = false;
2258
2259 // Look for pre-existing sword
2260
2/2
✓ Branch 0 taken 44466 times.
✓ Branch 1 taken 529734 times.
574200 for(int32_t i=0; i<Lwpns.Count(); i++)
2261 {
2262 529734 w = (weapon*)Lwpns.spr(i);
2263
2264
2/2
✓ Branch 0 taken 110307 times.
✓ Branch 1 taken 419427 times.
529734 if(w->id == (attack==wSword ? wSword : wWand))
2265 {
2266 419427 found = true;
2267 419427 break;
2268 }
2269 110307 }
2270
2271
2/2
✓ Branch 0 taken 419427 times.
✓ Branch 1 taken 44466 times.
463893 if(!found) // Create one if sword nonexistant
2272 {
2273
5/10
✓ Branch 0 taken 44466 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44466 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44466 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 44466 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 44466 times.
✗ Branch 9 not taken.
44466 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2274 44466 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2275
2276 44466 positionSword(w,itemid);
2277
2278 // Stone of Agony
2279
1/2
✓ Branch 0 taken 44466 times.
✗ Branch 1 not taken.
44466 if(agony)
2280 {
2281 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2282 }
2283 44466 }
2284
2285 // These are set by positionSword(), above or in checkstab()
2286 463893 yofs += slashyofs;
2287 463893 xofs += slashxofs;
2288 463893 slashyofs = slashxofs = 0;
2289 463893 }
2290 589652 }
2291
2292 836987 if(attackclk<7
2293
4/4
✓ Branch 0 taken 442131 times.
✓ Branch 1 taken 394856 times.
✓ Branch 2 taken 338682 times.
✓ Branch 3 taken 103449 times.
836987 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2294
4/6
✓ Branch 0 taken 73880 times.
✓ Branch 1 taken 264802 times.
✓ Branch 2 taken 73880 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 73880 times.
338682 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2295
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 72067 times.
73880 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2296
4/4
✓ Branch 0 taken 164852 times.
✓ Branch 1 taken 10664 times.
✓ Branch 2 taken 157722 times.
✓ Branch 3 taken 7130 times.
177329 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2297
4/4
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 162392 times.
✓ Branch 2 taken 17518 times.
✓ Branch 3 taken 144874 times.
175516 || (attack==wHammer && attackclk<=30)
2298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144874 times.
162392 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2299 {
2300
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 691813 times.
692113 if(!invisible)
2301 {
2302 691813 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2303
2/4
✓ Branch 0 taken 691813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 691813 times.
✗ Branch 3 not taken.
691813 if (FIXED_Z3_ANIMATION)
2304 {
2305 if (attackclk >= 2) tile += (extend==2?2:1);
2306 if (attackclk >= 13) tile += (extend==2?2:1);
2307 }
2308
2309
14/18
✓ Branch 0 taken 100685 times.
✓ Branch 1 taken 591128 times.
✓ Branch 2 taken 20231 times.
✓ Branch 3 taken 80454 times.
✓ Branch 4 taken 12975 times.
✓ Branch 5 taken 7256 times.
✓ Branch 6 taken 11775 times.
✓ Branch 7 taken 1200 times.
✓ Branch 8 taken 76056 times.
✓ Branch 9 taken 24629 times.
✓ Branch 10 taken 42834 times.
✓ Branch 11 taken 33222 times.
✓ Branch 12 taken 42834 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 42834 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
691813 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2310 {
2311 33222 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2312
2/4
✓ Branch 0 taken 33222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33222 times.
✗ Branch 3 not taken.
33222 if (FIXED_Z3_ANIMATION)
2313 {
2314 if (attackclk >= 7) tile += (extend==2?2:1);
2315 if (attackclk >= 11) tile += (extend==2?2:1);
2316 if (attackclk >= 14) tile += (extend==2?2:1);
2317 }
2318 33222 }
2319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 691813 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
691813 if (attack==wBugNet && !get_qr(qr_OLD_BUG_NET))
2320 {
2321 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2322 {
2323 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2324 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2325 }
2326 else
2327 {
2328 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2329 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2330 }
2331 }
2332
2333
4/4
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 669734 times.
✓ Branch 2 taken 13029 times.
✓ Branch 3 taken 9050 times.
691813 if((attack==wHammer) && (attackclk<13))
2334 {
2335 9050 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2336
2/4
✓ Branch 0 taken 9050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9050 times.
✗ Branch 3 not taken.
9050 if (FIXED_Z3_ANIMATION)
2337 {
2338 if (attackclk >= 14) tile += (extend==2?2:1);
2339 if (attackclk >= 16) tile += (extend==2?2:1);
2340 }
2341 9050 }
2342
2343
2/2
✓ Branch 0 taken 586925 times.
✓ Branch 1 taken 104888 times.
691813 if(useltm)
2344 {
2345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104888 times.
104888 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2346 104888 }
2347
2348 // Stone of Agony
2349
1/2
✓ Branch 0 taken 691813 times.
✗ Branch 1 not taken.
691813 if(agony)
2350 {
2351 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2352 }
2353
2354 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2355
2356 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2357
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 554107 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
691813 if (!(get_qr(qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2358 {
2359 680337 masked_draw(dest);
2360 680337 }
2361
2362 //Prevent flickering -Z
2363
1/2
✓ Branch 0 taken 691813 times.
✗ Branch 1 not taken.
691813 if (!getCanFlicker()) masked_draw(dest);
2364 691813 }
2365
2366
2/2
✓ Branch 0 taken 670034 times.
✓ Branch 1 taken 22079 times.
692113 if(attack!=wHammer)
2367 670034 goto herodraw_end;
2368 22079 }
2369
2370
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 144874 times.
166953 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2371 {
2372 22079 int32_t wy=1;
2373 22079 int32_t wx=1;
2374 22079 int32_t f=0,t,cs2;
2375 22079 weapon *w=NULL;
2376 22079 bool found = false;
2377
2378
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 21549 times.
22314 for(int32_t i=0; i<Lwpns.Count(); i++)
2379 {
2380 21549 w = (weapon*)Lwpns.spr(i);
2381
2382
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 21314 times.
21549 if(w->id == wHammer)
2383 {
2384 21314 found = true;
2385 21314 break;
2386 }
2387 235 }
2388
2389
2/2
✓ Branch 0 taken 21314 times.
✓ Branch 1 taken 765 times.
22079 if(!found)
2390 {
2391
5/10
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 765 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 765 times.
✗ Branch 9 not taken.
765 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2392 765 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2393 765 found = true;
2394 765 }
2395
2396 22079 t = w->o_tile;
2397 22079 cs2 = w->o_cset;
2398
2399
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3412 times.
✓ Branch 2 taken 4870 times.
✓ Branch 3 taken 6386 times.
✓ Branch 4 taken 7411 times.
22079 switch(dir)
2400 {
2401 case up:
2402 3412 wx=-1;
2403 3412 wy=-15;
2404
1/2
✓ Branch 0 taken 3412 times.
✗ Branch 1 not taken.
3412 if (IsSideSwim())wy+=hammer_swim_up_offset;
2405
2406
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 2010 times.
3412 if(attackclk>=13)
2407 {
2408 2010 wx-=1;
2409 2010 wy+=1;
2410 2010 ++t;
2411 2010 }
2412
2413
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1778 times.
3412 if(attackclk>=15)
2414 {
2415
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if (IsSideSwim())wy-=hammer_swim_up_offset;
2416 1778 ++t;
2417 1778 }
2418
2419 3412 break;
2420
2421 case down:
2422 4870 wx=3;
2423 4870 wy=-14;
2424
1/2
✓ Branch 0 taken 4870 times.
✗ Branch 1 not taken.
4870 if (IsSideSwim())wy+=hammer_swim_down_offset;
2425 4870 t+=3;
2426
2427
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 2849 times.
4870 if(attackclk>=13)
2428 {
2429 2849 wy+=16;
2430 2849 ++t;
2431 2849 }
2432
2433
2/2
✓ Branch 0 taken 2344 times.
✓ Branch 1 taken 2526 times.
4870 if(attackclk>=15)
2434 {
2435 2526 wx-=1;
2436 2526 wy+=12;
2437
1/2
✓ Branch 0 taken 2526 times.
✗ Branch 1 not taken.
2526 if (IsSideSwim())wy-=hammer_swim_down_offset;
2438 2526 ++t;
2439 2526 }
2440
2441 4870 break;
2442
2443 case left:
2444 6386 wx=0;
2445 6386 wy=-14;
2446
1/2
✓ Branch 0 taken 6386 times.
✗ Branch 1 not taken.
6386 if (IsSideSwim())wy+=hammer_swim_left_offset;
2447 6386 t+=6;
2448 6386 f=1;
2449
2450
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 3824 times.
6386 if(attackclk>=13)
2451 {
2452 3824 wx-=7;
2453 3824 wy+=8;
2454 3824 ++t;
2455 3824 }
2456
2457
2/2
✓ Branch 0 taken 2986 times.
✓ Branch 1 taken 3400 times.
6386 if(attackclk>=15)
2458 {
2459 3400 wx-=8;
2460 3400 wy+=8;
2461
1/2
✓ Branch 0 taken 3400 times.
✗ Branch 1 not taken.
3400 if (IsSideSwim())wy-=hammer_swim_left_offset;
2462 3400 ++t;
2463 3400 }
2464
2465 6386 break;
2466
2467 case right:
2468 7411 wx=0;
2469 7411 wy=-14;
2470
1/2
✓ Branch 0 taken 7411 times.
✗ Branch 1 not taken.
7411 if (IsSideSwim())wy+=hammer_swim_right_offset;
2471 7411 t+=6;
2472
2473
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 4346 times.
7411 if(attackclk>=13)
2474 {
2475 4346 wx+=7;
2476 4346 wy+=8;
2477 4346 ++t;
2478 4346 }
2479
2480
2/2
✓ Branch 0 taken 3558 times.
✓ Branch 1 taken 3853 times.
7411 if(attackclk>=15)
2481 {
2482 3853 wx+=8;
2483 3853 wy+=8;
2484
1/2
✓ Branch 0 taken 3853 times.
✗ Branch 1 not taken.
3853 if (IsSideSwim())wy-=hammer_swim_right_offset;
2485 3853 ++t;
2486 3853 }
2487
2488 7411 break;
2489 }
2490
2491
7/8
✓ Branch 0 taken 21929 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 18085 times.
✓ Branch 3 taken 3844 times.
✓ Branch 4 taken 18085 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1927 times.
✓ Branch 7 taken 16158 times.
22079 if(BSZ || ((isdungeon() && currscr<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2492 {
2493 16308 wy+=2;
2494 16308 }
2495
2496 // Stone of Agony
2497
1/2
✓ Branch 0 taken 22079 times.
✗ Branch 1 not taken.
22079 if(agony)
2498 {
2499 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2500 }
2501
2502 22079 w->x = x+wx;
2503 22079 w->y = y+wy-(54-yofs)-fakez;
2504 22079 w->z = (z+zofs);
2505 22079 w->tile = t;
2506 22079 w->flip = f;
2507 22079 w->hit_width=20;
2508 22079 w->hit_height=20;
2509
2510
2/2
✓ Branch 0 taken 13797 times.
✓ Branch 1 taken 8282 times.
22079 if(dir>down)
2511 {
2512 13797 w->hit_height-=6;
2513 13797 }
2514 else
2515 {
2516 8282 w->hit_width-=6;
2517 8282 w->hyofs=4;
2518 }
2519
2520 22079 w->power = weaponattackpower(itemid);
2521
2522
7/10
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 21345 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 734 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 732 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
22079 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2523 {
2524
3/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
734 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_qr(qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2525 734 }
2526
2527 22079 goto herodraw_end;
2528 }
2529 144874 }
2530
2/4
✓ Branch 0 taken 7480579 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7480579 times.
7480579 else if(!charging && !spins) // remove the sword
2531 {
2532
2/2
✓ Branch 0 taken 2019675 times.
✓ Branch 1 taken 7480579 times.
9500254 for(int32_t i=0; i<Lwpns.Count(); i++)
2533 {
2534 2019675 weapon *w = (weapon*)Lwpns.spr(i);
2535
2536
6/6
✓ Branch 0 taken 2018899 times.
✓ Branch 1 taken 776 times.
✓ Branch 2 taken 2018789 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 17390 times.
✓ Branch 5 taken 2001399 times.
2019675 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2537 18276 w->dead=1;
2538 2019675 }
2539 7480579 }
2540
2541
2/2
✓ Branch 0 taken 91420 times.
✓ Branch 1 taken 7534033 times.
7625453 if(invisible)
2542 {
2543 91420 goto herodraw_end;
2544 }
2545
2546
2/4
✓ Branch 0 taken 7534033 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7534033 times.
7534033 if(action != casting && action != sideswimcasting)
2547 {
2548 // Keep this consistent with checkspecial2, line 7800-ish...
2549
6/6
✓ Branch 0 taken 163847 times.
✓ Branch 1 taken 7370186 times.
✓ Branch 2 taken 156746 times.
✓ Branch 3 taken 7101 times.
✓ Branch 4 taken 7812 times.
✓ Branch 5 taken 148934 times.
7534033 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2550
2551 7534033 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2552 7534033 bool noliftspr = get_qr(qr_NO_LIFT_SPRITE);
2553 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2554
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6154206 times.
✓ Branch 3 taken 1379827 times.
7534033 switch(zinit.heroAnimationStyle)
2555 {
2556 case las_original: //normal
2557
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 6154142 times.
6154206 if(action==drowning)
2558 {
2559
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2560 {
2561 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2563 64 }
2564 else
2565 {
2566 goto herodraw_end;
2567 }
2568 64 }
2569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6154142 times.
6154142 else if(action==lavadrowning)
2570 {
2571 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2572 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2573 }
2574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6154142 times.
6154142 else if(action==sidedrowning)
2575 {
2576 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2577 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2578 }
2579
2/4
✓ Branch 0 taken 6154142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6154142 times.
6154142 else if (action == sideswimming || action == sideswimhit)
2580 {
2581 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2582
2583 if(lstep>=6)
2584 {
2585 if(dir==up)
2586 {
2587 if ( script_hero_sprite <= 0 ) ++flip;
2588 }
2589 else
2590 {
2591 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2592 }
2593 }
2594 }
2595
5/6
✓ Branch 0 taken 6082705 times.
✓ Branch 1 taken 71437 times.
✓ Branch 2 taken 6082185 times.
✓ Branch 3 taken 520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6082185 times.
6154142 else if(action==swimming || action==swimhit || hopclk==0xFF)
2596 {
2597 71957 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2598
2599
2/2
✓ Branch 0 taken 35932 times.
✓ Branch 1 taken 36025 times.
71957 if(lstep>=6)
2600 {
2601
2/2
✓ Branch 0 taken 7125 times.
✓ Branch 1 taken 28900 times.
36025 if(dir==up)
2602 {
2603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7125 times.
7125 if ( script_hero_sprite <= 0 ) ++flip;
2604 7125 }
2605 else
2606 {
2607
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28900 times.
28900 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2608 }
2609 36025 }
2610
2611
2/2
✓ Branch 0 taken 68768 times.
✓ Branch 1 taken 3189 times.
71957 if(isDiving())
2612 {
2613 3189 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3189 times.
3189 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2615 3189 }
2616 71957 }
2617
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 6080567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
6082185 else if(charging > 0 && attack != wHammer)
2618 {
2619 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2620
2621
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2622 {
2623
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2624 {
2625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2626 144 }
2627 else
2628 {
2629
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2630 }
2631 675 }
2632 1618 }
2633
9/12
✓ Branch 0 taken 6080325 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 6080325 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 5994762 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
6080567 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2634 {
2635 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2637 71761 }
2638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6008806 times.
6008806 else if(fallclk>0)
2639 {
2640 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2641 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2642 }
2643
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6008190 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6008806 else if(!noliftspr&&action==lifting&&isLifting())
2644 {
2645 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2646 if(script_hero_sprite <= 0)
2647 {
2648 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2649 auto speed = tliftclk/frames;
2650 if (speed < 1) speed = 1;
2651 auto curframe = (tliftclk - liftclk) / speed;
2652 if (!tliftclk) curframe = frames - 1;
2653 if(unsigned(curframe) < frames)
2654 tile += curframe * (extend == 2 ? 2 : 1);
2655 }
2656 }
2657 else
2658 {
2659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6008806 times.
6008806 if(IsSideSwim())
2660 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2661
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 6008190 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
6008806 else if(!noliftspr&&isLifting())
2662 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2663 6008806 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2664
2665
2/2
✓ Branch 0 taken 4496683 times.
✓ Branch 1 taken 1512123 times.
6008806 if(dir>up)
2666 {
2667 4496683 useltm=true;
2668 4496683 shieldModify=true;
2669 4496683 }
2670
2671
2/2
✓ Branch 0 taken 2933358 times.
✓ Branch 1 taken 3075448 times.
6008806 if(lstep>=6)
2672 {
2673
2/2
✓ Branch 0 taken 764170 times.
✓ Branch 1 taken 2311278 times.
3075448 if(dir==up)
2674 {
2675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764170 times.
764170 if ( script_hero_sprite <= 0 ) ++flip;
2676 764170 }
2677 else
2678 {
2679
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2311278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2311278 times.
2311278 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2680 }
2681 3075448 }
2682 }
2683
2684 6154206 break;
2685
2686 case las_bszelda: //BS
2687
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1379251 times.
1379827 if(action==drowning)
2688 {
2689
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(inwater)
2690 {
2691 576 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2693 576 }
2694 else
2695 {
2696 goto herodraw_end;
2697 }
2698 576 }
2699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1379251 times.
1379251 else if (action == sidedrowning)
2700 {
2701 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2702 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2703 }
2704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1379251 times.
1379251 else if(action==lavadrowning)
2705 {
2706 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2707 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2708 }
2709
2/4
✓ Branch 0 taken 1379251 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1379251 times.
1379251 else if (action == sideswimming || action == sideswimhit)
2710 {
2711 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2712
2713 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2714 }
2715
4/6
✓ Branch 0 taken 1374424 times.
✓ Branch 1 taken 4827 times.
✓ Branch 2 taken 1374424 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1374424 times.
1379251 else if(action==swimming || action==swimhit || hopclk==0xFF)
2716 {
2717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4827 times.
4827 if (get_qr(qr_COPIED_SWIM_SPRITES))
2718 {
2719 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2720 }
2721 else
2722 {
2723 4827 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2724 }
2725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4827 times.
4827 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2726
2727
2/2
✓ Branch 0 taken 4183 times.
✓ Branch 1 taken 644 times.
4827 if(isDiving())
2728 {
2729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if (get_qr(qr_COPIED_SWIM_SPRITES))
2730 {
2731 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2732 }
2733 else
2734 {
2735 644 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2736 }
2737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2738 644 }
2739 4827 }
2740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1374424 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1374424 else if(charging > 0 && attack != wHammer)
2741 {
2742 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2743 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2744 }
2745
8/10
✓ Branch 0 taken 1370669 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 1370669 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1373269 times.
✓ Branch 6 taken 905 times.
✓ Branch 7 taken 250 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 905 times.
1374424 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2746 {
2747 905 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 905 times.
905 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2749 905 }
2750
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 1373029 times.
1373519 else if(fallclk>0)
2751 {
2752 490 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2754 490 }
2755
5/6
✓ Branch 0 taken 25908 times.
✓ Branch 1 taken 1347121 times.
✓ Branch 2 taken 199 times.
✓ Branch 3 taken 25709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 199 times.
1373029 else if(!noliftspr&&action==lifting&&isLifting())
2756 {
2757 199 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(script_hero_sprite <= 0)
2759 {
2760 199 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2761 199 auto speed = tliftclk/frames;
2762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if (speed < 1) speed = 1;
2763 199 auto curframe = (tliftclk - liftclk) / speed;
2764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if (!tliftclk) curframe = frames - 1;
2765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
199 if(unsigned(curframe) < frames)
2766 199 tile += curframe * (extend == 2 ? 2 : 1);
2767 199 }
2768 199 }
2769 else
2770 {
2771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1372830 times.
1372830 if(IsSideSwim())
2772 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2773
4/4
✓ Branch 0 taken 25709 times.
✓ Branch 1 taken 1347121 times.
✓ Branch 2 taken 24643 times.
✓ Branch 3 taken 1066 times.
1372830 else if(!noliftspr&&isLifting())
2774 1066 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2775 1371764 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2776
2777
2/2
✓ Branch 0 taken 419120 times.
✓ Branch 1 taken 953710 times.
1372830 if(dir>up)
2778 {
2779 953710 useltm=true;
2780 953710 shieldModify=true;
2781 953710 }
2782
2783 /*
2784 else if (dir==up)
2785 {
2786 useltm=true;
2787 }
2788 */
2789
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 1370270 times.
1372830 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2790 }
2791
2792 1379827 break;
2793
2794 case las_zelda3slow: //8-frame Zelda 3 (slow)
2795 case las_zelda3: //8-frame Zelda 3
2796 if(action == drowning)
2797 {
2798 if(inwater)
2799 {
2800 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2801 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2802 }
2803 else
2804 {
2805 goto herodraw_end;
2806 }
2807 }
2808 else if(action == lavadrowning)
2809 {
2810 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2811 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2812
2813 }
2814 else if(action == sidedrowning)
2815 {
2816 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2817 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2818 }
2819 else if (action == sideswimming || action == sideswimhit)
2820 {
2821 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2822
2823 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2824 }
2825 else if(action == swimming || action==swimhit || hopclk==0xFF)
2826 {
2827 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2828 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2829
2830 if(isDiving())
2831 {
2832 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2833 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2834 }
2835 }
2836 else if(charging > 0 && attack != wHammer)
2837 {
2838 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2839 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2840 //int32_t l=hero_count/hero_animation_speed;
2841 int32_t l=(hero_count/hero_animation_speed)&15;
2842 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2843 l-=((l>3)?1:0)+((l>12)?1:0);
2844 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2845 }
2846 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2847 {
2848 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2849 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2850 }
2851 else if(fallclk>0)
2852 {
2853 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2854 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2855 }
2856 else if(!noliftspr&&action==lifting&&isLifting())
2857 {
2858 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2859 if(script_hero_sprite <= 0)
2860 {
2861 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2862 auto speed = tliftclk/frames;
2863 if (speed < 1) speed = 1;
2864 auto curframe = (tliftclk-liftclk)/speed;
2865 if (!tliftclk) curframe = frames - 1;
2866 if(unsigned(curframe) < frames)
2867 tile += curframe * (extend == 2 ? 2 : 1);
2868 }
2869 }
2870 else
2871 {
2872 if(IsSideSwim())
2873 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2874 else if(!noliftspr&&isLifting())
2875 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2876 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2877
2878 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2879 {
2880 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2881 }
2882
2883 if(dir>up)
2884 {
2885 useltm=true;
2886 shieldModify=true;
2887 }
2888
2889 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2890 {
2891 //tile+=(extend==2?2:1);
2892 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2893 int32_t l = hero_count / hero_animation_speed;
2894 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2895 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2896 }
2897 }
2898
2899 break;
2900
2901 default:
2902 break;
2903 }
2904 7534033 }
2905
2906
6/6
✓ Branch 0 taken 5706695 times.
✓ Branch 1 taken 1827338 times.
✓ Branch 2 taken 3538773 times.
✓ Branch 3 taken 2167922 times.
✓ Branch 4 taken 158886 times.
✓ Branch 5 taken 3379887 times.
7534033 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2907
2908
2/2
✓ Branch 0 taken 7531096 times.
✓ Branch 1 taken 2937 times.
7534033 if(action==won)
2909 {
2910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2937 times.
2937 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2911 2937 }
2912
2913
4/4
✓ Branch 0 taken 7477726 times.
✓ Branch 1 taken 56307 times.
✓ Branch 2 taken 50638 times.
✓ Branch 3 taken 7427088 times.
7534033 if(action==landhold1 || action==landhold2)
2914 {
2915 106945 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2916
6/6
✓ Branch 0 taken 80375 times.
✓ Branch 1 taken 26570 times.
✓ Branch 2 taken 59850 times.
✓ Branch 3 taken 20525 times.
✓ Branch 4 taken 13567 times.
✓ Branch 5 taken 46283 times.
106945 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2917 106945 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2918 106945 }
2919
4/4
✓ Branch 0 taken 7426438 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 599 times.
✓ Branch 3 taken 7425839 times.
7427088 else if(action==waterhold1 || action==waterhold2)
2920 {
2921 1249 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2922 1249 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2923 1249 }
2924
2/4
✓ Branch 0 taken 7425839 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7425839 times.
7425839 else if(action==sidewaterhold1 || action==sidewaterhold2)
2925 {
2926 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2927 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2928 }
2929
2930
2/4
✓ Branch 0 taken 7534033 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7534033 times.
7534033 if(action!=casting && action!=sideswimcasting)
2931 {
2932
2/2
✓ Branch 0 taken 1584550 times.
✓ Branch 1 taken 5949483 times.
7534033 if(useltm)
2933 {
2934
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 5946923 times.
5949483 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2935 5949483 }
2936 7534033 }
2937
2938 // Stone of Agony
2939
2/2
✓ Branch 0 taken 7534001 times.
✓ Branch 1 taken 32 times.
7534033 if(agony)
2940 {
2941
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2942 32 }
2943
2944
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 6370677 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
7534033 if(!(get_qr(qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2945 {
2946 7474973 masked_draw(dest);
2947 7474973 }
2948
2949 //draw held items after Hero so they don't go behind his head
2950
4/4
✓ Branch 0 taken 7477726 times.
✓ Branch 1 taken 56307 times.
✓ Branch 2 taken 50638 times.
✓ Branch 3 taken 7427088 times.
7534033 if(action==landhold1 || action==landhold2)
2951 {
2952
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 106927 times.
106945 if(holditem > -1)
2953 {
2954
2/2
✓ Branch 0 taken 56874 times.
✓ Branch 1 taken 50053 times.
106927 if(get_qr(qr_HOLDITEMANIMATION))
2955 {
2956 56874 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2957 56874 }
2958 else
2959 {
2960 50053 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
2961 }
2962 106927 }
2963 106945 }
2964
4/4
✓ Branch 0 taken 7426438 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 599 times.
✓ Branch 3 taken 7425839 times.
7427088 else if(action==waterhold1 || action==waterhold2)
2965 {
2966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1249 times.
1249 if(holditem > -1)
2967 {
2968
2/2
✓ Branch 0 taken 989 times.
✓ Branch 1 taken 260 times.
1249 if(get_qr(qr_HOLDITEMANIMATION))
2969 {
2970 989 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2971 989 }
2972 else
2973 {
2974 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
2975 }
2976 1249 }
2977 1249 }
2978
2/4
✓ Branch 0 taken 7425839 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7425839 times.
7425839 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2979 {
2980 if(holditem > -1)
2981 {
2982 if(get_qr(qr_HOLDITEMANIMATION))
2983 {
2984 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2985 }
2986 else
2987 {
2988 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z,holditem);
2989 }
2990 }
2991 }
2992
4/4
✓ Branch 0 taken 18756 times.
✓ Branch 1 taken 7515277 times.
✓ Branch 2 taken 3393 times.
✓ Branch 3 taken 15363 times.
7534033 if(fairyclk==0||(get_qr(qr_NOHEARTRING)))
2993 {
2994 7518670 goto herodraw_end;
2995 }
2996
2997 15363 double a2 = fairyclk*4.5 + 90;
2998 15363 int32_t hearts=0;
2999 15363 int32_t htile = 2;
3000
3001 15363 do
3002 {
3003 93504 int32_t nx=125;
3004
3005
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 36960 times.
93504 if(get_qr(qr_HEARTRINGFIX))
3006 {
3007 36960 nx=x;
3008 36960 }
3009
3010 93504 int32_t ny=88;
3011
3012
2/2
✓ Branch 0 taken 56544 times.
✓ Branch 1 taken 36960 times.
93504 if(get_qr(qr_HEARTRINGFIX))
3013 {
3014 36960 ny=y;
3015 36960 }
3016
3017 93504 int32_t tx = zc::math::CosD(a2)*53 +nx;
3018 93504 int32_t ty = -zc::math::SinD(a2)*53 +ny+playing_field_offset;
3019 93504 overtile8(dest,htile,tx,ty,1,0);
3020 93504 a2-=45;
3021 93504 ++hearts;
3022
2/2
✓ Branch 0 taken 78141 times.
✓ Branch 1 taken 15363 times.
187008 }
3023
2/2
✓ Branch 0 taken 8400 times.
✓ Branch 1 taken 85104 times.
93504 while(a2>90 && hearts<8);
3024 15363 }
3025 herodraw_end:
3026 8323146 xofs=oxofs;
3027 8323146 yofs=oyofs;
3028 8323146 do_primitives(dest, SPLAYER_PLAYER_DRAW, tmpscr, 0, playing_field_offset);
3029 8323146 }
3030
3031 8155310 void HeroClass::masked_draw(BITMAP* dest)
3032 {
3033 8155310 zfix lz, lfz;
3034
2/2
✓ Branch 0 taken 8154045 times.
✓ Branch 1 taken 1265 times.
8155310 if(lift_wpn)
3035 {
3036 1265 lz = lift_wpn->z;
3037 1265 lfz = lift_wpn->fakez;
3038 1265 }
3039
3040
12/12
✓ Branch 0 taken 4040350 times.
✓ Branch 1 taken 4114960 times.
✓ Branch 2 taken 3870328 times.
✓ Branch 3 taken 170022 times.
✓ Branch 4 taken 3819782 times.
✓ Branch 5 taken 50546 times.
✓ Branch 6 taken 3765442 times.
✓ Branch 7 taken 54340 times.
✓ Branch 8 taken 3686289 times.
✓ Branch 9 taken 79153 times.
✓ Branch 10 taken 3726517 times.
✓ Branch 11 taken 143811 times.
8155310 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_qr(qr_FREEFORM))
3041 {
3042 // clip under doorways
3043 143811 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3044
3045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143811 times.
143811 if(sub!=NULL)
3046 {
3047 143811 yofs -= (playing_field_offset+16);
3048 143811 xofs -= 16;
3049 143811 sprite::draw(sub);
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143811 times.
143811 if(lift_wpn)
3051 {
3052 handle_lift(false);
3053 bool shad = lift_wpn->has_shadow;
3054 lift_wpn->has_shadow = false;
3055 lift_wpn->z += z;
3056 lift_wpn->fakez += fakez;
3057 lift_wpn->draw(sub);
3058 lift_wpn->has_shadow = shad;
3059 }
3060 143811 prompt_draw(sub);
3061 143811 xofs+=16;
3062 143811 yofs += (playing_field_offset+16);
3063 143811 destroy_bitmap(sub);
3064 143811 }
3065 143811 }
3066 else
3067 {
3068 8011499 sprite::draw(dest);
3069
2/2
✓ Branch 0 taken 8010234 times.
✓ Branch 1 taken 1265 times.
8011499 if(lift_wpn)
3070 {
3071 1265 handle_lift(false);
3072 1265 bool shad = lift_wpn->has_shadow;
3073 1265 lift_wpn->has_shadow = false;
3074 1265 lift_wpn->z += z;
3075 1265 lift_wpn->fakez += fakez;
3076 1265 lift_wpn->draw(dest);
3077 1265 lift_wpn->has_shadow = shad;
3078 1265 }
3079 8011499 prompt_draw(dest);
3080 }
3081
3082
2/2
✓ Branch 0 taken 8154045 times.
✓ Branch 1 taken 1265 times.
8155310 if(lift_wpn)
3083 {
3084 1265 lift_wpn->z = lz;
3085 1265 lift_wpn->fakez = lfz;
3086 1265 }
3087 8155310 return;
3088 }
3089 8155310 void HeroClass::prompt_draw(BITMAP* dest)
3090 {
3091
2/2
✓ Branch 0 taken 8153261 times.
✓ Branch 1 taken 2049 times.
8155310 if(!prompt_combo) return;
3092 2049 int32_t sx = real_x(x+xofs+prompt_x);
3093 2049 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3094 2049 sy -= fake_z(fakez);
3095 2049 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3096 2049 return;
3097 8155310 }
3098
3099 10576 void collectitem_script(int32_t id)
3100 {
3101
2/2
✓ Branch 0 taken 10382 times.
✓ Branch 1 taken 194 times.
10576 if(itemsbuf[id].collect_script)
3102 {
3103 //clear item script stack.
3104 194 FFCore.ref(ScriptType::Item, -id).Clear();
3105
3106
2/6
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 194 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
194 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3107 {
3108 194 int i = -id;
3109 194 FFCore.reset_script_engine_data(ScriptType::Item, i);
3110 194 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3111 194 FFCore.deallocateAllArrays(ScriptType::Item, i);
3112 194 }
3113 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3114 {
3115 int i = COLLECT_SCRIPT_ITEM_ZERO;
3116 FFCore.reset_script_engine_data(ScriptType::Item, i);
3117 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3118 FFCore.deallocateAllArrays(ScriptType::Item, i);
3119 }
3120 //runningItemScripts[id] = 0;
3121 194 }
3122 10576 }
3123 1012 void passiveitem_script(int32_t id, bool doRun = false)
3124 {
3125 //Passive item scripts on colelction
3126
3/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 974 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1012 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ))
3127 {
3128 FFCore.reset_script_engine_data(ScriptType::Item, id);
3129
3130 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3131 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3132 {
3133 FFCore.doscript(ScriptType::Item, id) = false;
3134 return;
3135 }
3136 if(doRun)
3137 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3138 }
3139 1012 }
3140
3141 // separate case for sword/wand/hammer/slashed weapons only
3142 // the main weapon checking is in the global function check_collisions()
3143 7262477 bool HeroClass::checkstab()
3144 {
3145
14/14
✓ Branch 0 taken 6440606 times.
✓ Branch 1 taken 821871 times.
✓ Branch 2 taken 222176 times.
✓ Branch 3 taken 599695 times.
✓ Branch 4 taken 200894 times.
✓ Branch 5 taken 21282 times.
✓ Branch 6 taken 178815 times.
✓ Branch 7 taken 22079 times.
✓ Branch 8 taken 178787 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 165516 times.
✓ Branch 11 taken 13271 times.
✓ Branch 12 taken 188123 times.
✓ Branch 13 taken 468232 times.
7262477 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3146 821871 || (attackclk<=4))
3147 6794245 return false;
3148
3149 468232 weapon *w=NULL;
3150
3151 468232 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3152 468232 bool found = false;
3153 468232 int32_t melee_weapon_index = 0;
3154 468232 int32_t parentitem=-1;
3155 468232 weapon* meleeweap = nullptr;
3156
2/2
✓ Branch 0 taken 47458 times.
✓ Branch 1 taken 539998 times.
587456 for(int32_t i=0; i<Lwpns.Count(); i++)
3157 {
3158 539998 w = (weapon*)Lwpns.spr(i);
3159
3160
6/6
✓ Branch 0 taken 539960 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 11766 times.
✓ Branch 3 taken 528194 times.
✓ Branch 4 taken 119224 times.
✓ Branch 5 taken 420774 times.
539998 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3161 {
3162 420774 found = true;
3163 420774 melee_weapon_index = i+1;
3164 420774 meleeweap = w;
3165 // Position the sword as Hero slashes with it.
3166
3/4
✓ Branch 0 taken 401744 times.
✓ Branch 1 taken 19030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 401744 times.
420774 if(w->id!=wHammer&&w->id!=wBugNet)
3167 401744 positionSword(w,w->parentitem);
3168
3169 420774 wx=w->x;
3170 420774 wy=w->y;
3171 420774 wz=w->z;
3172 420774 wxsz = w->hit_width;
3173 420774 wysz = w->hit_height;
3174 420774 parentitem = w->parentitem;
3175 420774 break;
3176 }
3177 119224 }
3178
3179
6/6
✓ Branch 0 taken 424886 times.
✓ Branch 1 taken 43346 times.
✓ Branch 2 taken 43628 times.
✓ Branch 3 taken 381258 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 41822 times.
468232 if(attack==wSword && attackclk>=14 && charging==0)
3180 41822 return false;
3181
3182
2/2
✓ Branch 0 taken 378952 times.
✓ Branch 1 taken 47458 times.
426410 if(!found)
3183 47458 return false;
3184
3185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 378952 times.
378952 if(attack == wFire)
3186 return false;
3187
3188
2/2
✓ Branch 0 taken 359922 times.
✓ Branch 1 taken 19030 times.
378952 if(attack==wHammer)
3189 {
3190
2/2
✓ Branch 0 taken 7473 times.
✓ Branch 1 taken 11557 times.
19030 if(attackclk<15)
3191 {
3192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 1702 times.
✓ Branch 3 taken 2090 times.
✓ Branch 4 taken 2529 times.
7473 switch(w->dir)
3193 {
3194 case up:
3195 1152 wx=x-1;
3196 1152 wy=y-4;
3197 1152 break;
3198
3199 case down:
3200 1702 wx=x+8;
3201 1702 wy=y+28;
3202 1702 break; // This is consistent with 2.10
3203
3204 case left:
3205 2090 wx=x-13;
3206 2090 wy=y+14;
3207 2090 break;
3208
3209 case right:
3210 2529 wx=x+21;
3211 2529 wy=y+14;
3212 2529 break;
3213 }
3214
3215
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 6732 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
7473 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3216 {
3217 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3218 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3219 switch(dir)
3220 {
3221 case up:
3222 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3223 break;
3224
3225 case down:
3226 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3227 break;
3228
3229 case left:
3230 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3231 break;
3232
3233 case right:
3234 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3235 break;
3236 }
3237 */
3238 739 }
3239
3240 7473 return false;
3241 }
3242
2/2
✓ Branch 0 taken 10823 times.
✓ Branch 1 taken 734 times.
11557 else if(attackclk==15)
3243 {
3244 // Hammer's reach needs adjusted slightly for backward compatibility
3245
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 114 times.
734 if(w->dir==up)
3246 114 w->hyofs-=1;
3247
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 207 times.
620 else if(w->dir==left)
3248 207 w->hxofs-=2;
3249 734 }
3250 11557 }
3251
3252 // The return of Spaghetti Code Constants!
3253
6/6
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 357857 times.
✓ Branch 2 taken 346282 times.
✓ Branch 3 taken 11575 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 11557 times.
371479 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3254
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 354105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
371479 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3255 371479 itemid = vbound(itemid, 0, MAXITEMS-1);
3256
3257 // The sword offsets aren't based on anything other than what felt about right
3258 // compared to the NES game and what mostly kept it from hitting things that
3259 // should clearly be out of range. They could probably still use more tweaking.
3260 // Don't use 2.10 for reference; it's pretty far off.
3261 // - Saf
3262
3263
6/6
✓ Branch 0 taken 56851 times.
✓ Branch 1 taken 314628 times.
✓ Branch 2 taken 5420 times.
✓ Branch 3 taken 51431 times.
✓ Branch 4 taken 8227 times.
✓ Branch 5 taken 48624 times.
371479 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3264 {
3265
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8872 times.
✓ Branch 2 taken 10878 times.
✓ Branch 3 taken 14444 times.
✓ Branch 4 taken 14430 times.
48624 switch(w->dir)
3266 {
3267 case up:
3268
2/2
✓ Branch 0 taken 5792 times.
✓ Branch 1 taken 3080 times.
8872 if(attackclk<8)
3269 {
3270 3080 wy-=4;
3271 3080 }
3272
3273 8872 break;
3274
3275 case down:
3276 //if(attackclk<8)
3277 {
3278 10878 wy-=2;
3279 }
3280 10878 break;
3281
3282 case left:
3283
3284 //if(attackclk<8)
3285 {
3286 14444 wx+=2;
3287 }
3288
3289 14444 break;
3290
3291 case right:
3292
3293 //if(attackclk<8)
3294 {
3295 14430 wx-=3;
3296 //wy+=((spins>0 || get_qr(qr_SLASHFLIPFIX)) ? -4 : 4);
3297 }
3298
3299 14430 break;
3300 }
3301 48624 }
3302
3303
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 84047 times.
✓ Branch 2 taken 80133 times.
✓ Branch 3 taken 102432 times.
✓ Branch 4 taken 104867 times.
371479 switch(w->dir)
3304 {
3305 case up:
3306 84047 wx+=2;
3307 84047 break;
3308
3309 case down:
3310 80133 break;
3311
3312 case left:
3313 102432 wy-=3;
3314 102432 break;
3315
3316 case right:
3317 104867 wy-=3;
3318 104867 break;
3319 }
3320
3321 371479 wx+=w->hxofs;
3322 371479 wy+=w->hyofs;
3323 371479 wy-=(w->fakez).getInt();
3324
3325
2/2
✓ Branch 0 taken 368163 times.
✓ Branch 1 taken 1787906 times.
2156069 for(int32_t i=0; i<guys.Count(); i++)
3326 {
3327
1/2
✓ Branch 0 taken 1787906 times.
✗ Branch 1 not taken.
1787906 if(attack==wBugNet) break;
3328 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3329
6/6
✓ Branch 0 taken 36426 times.
✓ Branch 1 taken 1751480 times.
✓ Branch 2 taken 35947 times.
✓ Branch 3 taken 479 times.
✓ Branch 4 taken 35303 times.
✓ Branch 5 taken 644 times.
1788220 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3330
5/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1125 times.
✓ Branch 2 taken 1653302 times.
✓ Branch 3 taken 98314 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1751616 times.
1752603 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3331
4/4
✓ Branch 0 taken 47794 times.
✓ Branch 1 taken 1703822 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 47480 times.
1751616 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3332 {
3333 // Checking the whimsical ring for every collision check causes
3334 // an odd bug. It's much more likely to activate on a 0-damage
3335 // weapon, since a 0-damage hit won't make the enemy invulnerable
3336 // to damaging hits in the following frames.
3337
3338 36428 int32_t whimsyid = current_item_id(itype_whimsicalring);
3339
3340 36428 int32_t dmg = weaponattackpower(itemid);
3341
2/2
✓ Branch 0 taken 34519 times.
✓ Branch 1 taken 1909 times.
36428 if(whimsyid>-1)
3342 {
3343
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3344 116 dmg += current_item_power(itype_whimsicalring);
3345 1793 else whimsyid = -1;
3346 1909 }
3347 36428 int32_t atkringid = current_item_id(itype_atkring);
3348
2/2
✓ Branch 0 taken 36420 times.
✓ Branch 1 taken 8 times.
36428 if(atkringid>-1)
3349 {
3350 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3351 8 dmg += itemsbuf[atkringid].misc1; //Additive
3352 8 }
3353
3354 36428 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3355 36428 enemy *e = (enemy*)guys.spr(i);
3356
2/2
✓ Branch 0 taken 12260 times.
✓ Branch 1 taken 24168 times.
36428 if (h == -1)
3357 {
3358 24168 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3359 24168 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
3360 24168 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3361
1/2
✓ Branch 0 taken 24168 times.
✗ Branch 1 not taken.
24168 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
3362 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3363 24168 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3364 24168 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3365 24168 } //temp_hit = true; }
3366 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3367
3368
4/4
✓ Branch 0 taken 24168 times.
✓ Branch 1 taken 12260 times.
✓ Branch 2 taken 24123 times.
✓ Branch 3 taken 45 times.
36428 if(h<0 && whimsyid>-1)
3369 {
3370 45 sfx(itemsbuf[whimsyid].usesound);
3371 45 }
3372
3373
4/4
✓ Branch 0 taken 31636 times.
✓ Branch 1 taken 4792 times.
✓ Branch 2 taken 31542 times.
✓ Branch 3 taken 94 times.
36428 if(h && charging>0)
3374 {
3375 94 attackclk = SWORDTAPFRAME;
3376 94 spins=0;
3377 94 }
3378
3379
8/8
✓ Branch 0 taken 31636 times.
✓ Branch 1 taken 4792 times.
✓ Branch 2 taken 27415 times.
✓ Branch 3 taken 4221 times.
✓ Branch 4 taken 27406 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 27398 times.
36428 if(h && hclk==0 && inlikelike != 1 && !get_qr(qr_DYING_ENEMIES_IGNORE_STUN))
3380 {
3381
2/2
✓ Branch 0 taken 27277 times.
✓ Branch 1 taken 121 times.
27398 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3382 {
3383 121 hithero(i);
3384 121 }
3385 27398 }
3386
3387
2/2
✓ Branch 0 taken 32974 times.
✓ Branch 1 taken 3454 times.
36428 if(h==2)
3388 3454 break;
3389 32974 }
3390 1784590 }
3391
3392
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 371323 times.
743096 if(attack == wBugNet
3393
3/4
✓ Branch 0 taken 371479 times.
✓ Branch 1 taken 138 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 371479 times.
371617 || (parentitem==-1&&!get_qr(qr_NOITEMMELEE))
3394
1/2
✓ Branch 0 taken 371479 times.
✗ Branch 1 not taken.
371479 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3395 {
3396
1/4
✓ Branch 0 taken 371461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
371461 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3397
2/2
✓ Branch 0 taken 371461 times.
✓ Branch 1 taken 102700 times.
474161 for(int32_t j=0; j<items.Count(); j++)
3398 {
3399 102700 item* ptr = (item*)items.spr(j);
3400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102700 times.
102700 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3401 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3402
3403
2/4
✓ Branch 0 taken 102700 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102700 times.
✗ Branch 3 not taken.
102700 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3404 continue; //No picking these up unless you have a bottle to fill!
3405
5/6
✓ Branch 0 taken 102673 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 19458 times.
✓ Branch 3 taken 83215 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19458 times.
102700 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3406 {
3407
7/8
✓ Branch 0 taken 83215 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 37368 times.
✓ Branch 3 taken 45847 times.
✓ Branch 4 taken 45874 times.
✓ Branch 5 taken 37368 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 45874 times.
83242 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3408 {
3409
6/6
✓ Branch 0 taken 43078 times.
✓ Branch 1 taken 2796 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 42117 times.
✓ Branch 4 taken 43069 times.
✓ Branch 5 taken 2805 times.
88951 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3410
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 42354 times.
✓ Branch 3 taken 723 times.
43078 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3411 {
3412 2805 int32_t pickup = ptr->pickup;
3413 2805 int32_t id2 = ptr->id;
3414 2805 int32_t pstr = ptr->pstring;
3415 2805 int32_t pstr_flags = ptr->pickup_string_flags;
3416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
2805 if(!dofairy)
3417 {
3418 2805 std::vector<int32_t> &ev = FFCore.eventData;
3419 2805 ev.clear();
3420 2805 ev.push_back(id2*10000);
3421 2805 ev.push_back(pickup*10000);
3422 2805 ev.push_back(pstr*10000);
3423 2805 ev.push_back(pstr_flags*10000);
3424 2805 ev.push_back(0);
3425 2805 ev.push_back(ptr->getUID());
3426 2805 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3427 2805 ev.push_back(w->getUID());
3428
3429 2805 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3430 2805 bool nullify = ev[4] != 0;
3431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
2805 if(nullify) continue;
3432 2805 id2 = ev[0]/10000;
3433 2805 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3434 2805 pstr = ev[2] / 10000;
3435 2805 pstr_flags = ev[3] / 10000;
3436 2805 }
3437
3438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
2805 if(pickup&ipONETIME) // set mITEM for one-time-only items
3439 setmapflag(mITEM);
3440
1/2
✓ Branch 0 taken 2805 times.
✗ Branch 1 not taken.
2805 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3441 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3442
3443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2805 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3444 setxmapflag(1<<ptr->pickupexstate);
3445
1/2
✓ Branch 0 taken 2805 times.
✗ Branch 1 not taken.
2805 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3446 {
3447 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3448 hidden_entrance(0, true, false, -5);
3449 }
3450 //!DIMI
3451
3452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
2805 if(dofairy)
3453 {
3454 game->fillBottle(itemsbuf[ptr->id].misc4);
3455 }
3456 else
3457 {
3458 2805 collectitem_script(id2);
3459
3460 2805 getitem(id2, false, true);
3461 }
3462 2805 items.del(j);
3463
3464
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 2805 times.
6207 for(int32_t i=0; i<Lwpns.Count(); i++)
3465 {
3466 3402 weapon *w2 = (weapon*)Lwpns.spr(i);
3467
3468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3402 times.
3402 if(w2->dragging==j)
3469 {
3470 w2->dragging=-1;
3471 }
3472
1/2
✓ Branch 0 taken 3402 times.
✗ Branch 1 not taken.
3402 else if(w2->dragging>j)
3473 {
3474 w2->dragging-=1;
3475 }
3476 3402 }
3477
3478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2805 if ( (pstr > 0 && pstr < msg_count) )
3479 {
3480 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3481 {
3482 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3483 FFCore.SetItemMessagePlayed(id2);
3484 donewmsg(pstr);
3485 break;
3486 }
3487 }
3488
3489 2805 --j;
3490 2805 }
3491 45874 }
3492 83242 }
3493 102700 }
3494 371461 }
3495
3496
3/4
✓ Branch 0 taken 371461 times.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 371461 times.
371617 if(attack==wCByrna || attack==wBugNet)
3497 156 return false;
3498
3499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 371461 times.
371461 if(meleeweap->no_triggers())
3500 return false;
3501
3502
2/2
✓ Branch 0 taken 346282 times.
✓ Branch 1 taken 25179 times.
371461 if(attack==wSword)
3503 {
3504
2/2
✓ Branch 0 taken 303415 times.
✓ Branch 1 taken 42867 times.
346282 if(attackclk == 6)
3505 {
3506
2/2
✓ Branch 0 taken 7544592 times.
✓ Branch 1 taken 42867 times.
7587459 for(int32_t q=0; q<176; q++)
3507 {
3508 7544592 set_bit(screengrid,q,0);
3509 7544592 set_bit(screengrid_layer[0],q,0);
3510 7544592 set_bit(screengrid_layer[1],q,0);
3511 7544592 }
3512
3513
2/2
✓ Branch 0 taken 685872 times.
✓ Branch 1 taken 42867 times.
728739 for(dword q = MAXFFCS/8; q > 0; --q)
3514 685872 ffcgrid[q-1] = 0;
3515 42867 }
3516
3517
4/4
✓ Branch 0 taken 79614 times.
✓ Branch 1 taken 266668 times.
✓ Branch 2 taken 39843 times.
✓ Branch 3 taken 39771 times.
346282 if(dir==up && ((x.getInt()&15)==0))
3518 {
3519 39843 check_slash_block(wx,wy);
3520 39843 check_slash_block(wx,wy+8);
3521
3522 //layers
3523 39843 check_slash_block_layer(wx,wy,1);
3524 39843 check_slash_block_layer(wx,wy+8,1);
3525 39843 check_slash_block_layer(wx,wy,1);
3526 39843 check_slash_block_layer(wx,wy+8,1);
3527 //2
3528 39843 check_slash_block_layer(wx,wy,2);
3529 39843 check_slash_block_layer(wx,wy+8,2);
3530 39843 check_slash_block_layer(wx,wy,2);
3531 39843 check_slash_block_layer(wx,wy+8,2);
3532 39843 }
3533
8/10
✓ Branch 0 taken 39771 times.
✓ Branch 1 taken 266668 times.
✓ Branch 2 taken 1969 times.
✓ Branch 3 taken 37802 times.
✓ Branch 4 taken 167 times.
✓ Branch 5 taken 1802 times.
✓ Branch 6 taken 167 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 167 times.
306439 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3534 {
3535 39604 check_slash_block(wx,wy);
3536 39604 check_slash_block(wx,wy+8);
3537 39604 check_slash_block(wx+8,wy);
3538 39604 check_slash_block(wx+8,wy+8);
3539 ///layer 1
3540 39604 check_slash_block_layer(wx,wy,1);
3541 39604 check_slash_block_layer(wx,wy+8,1);
3542 39604 check_slash_block_layer(wx+8,wy,1);
3543 39604 check_slash_block_layer(wx+8,wy+8,1);
3544 ///layer 2
3545 39604 check_slash_block_layer(wx,wy,2);
3546 39604 check_slash_block_layer(wx,wy+8,2);
3547 39604 check_slash_block_layer(wx+8,wy,2);
3548 39604 check_slash_block_layer(wx+8,wy+8,2);
3549 39604 }
3550
4/4
✓ Branch 0 taken 75645 times.
✓ Branch 1 taken 270637 times.
✓ Branch 2 taken 36104 times.
✓ Branch 3 taken 39541 times.
346282 if(dir==down && ((x.getInt()&15)==0))
3551 {
3552 39541 check_slash_block(wx,wy+wysz-8);
3553 39541 check_slash_block(wx,wy+wysz);
3554
3555 //layer 1
3556 39541 check_slash_block_layer(wx,wy+wysz-8,1);
3557 39541 check_slash_block_layer(wx,wy+wysz,1);
3558 //layer 2
3559 39541 check_slash_block_layer(wx,wy+wysz-8,2);
3560 39541 check_slash_block_layer(wx,wy+wysz,2);
3561 39541 }
3562
8/10
✓ Branch 0 taken 36104 times.
✓ Branch 1 taken 270637 times.
✓ Branch 2 taken 3495 times.
✓ Branch 3 taken 32609 times.
✓ Branch 4 taken 98 times.
✓ Branch 5 taken 3397 times.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 98 times.
306741 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3563 {
3564 36006 check_slash_block(wx,wy+wysz-8);
3565 36006 check_slash_block(wx,wy+wysz);
3566 36006 check_slash_block(wx+8,wy+wysz-8);
3567 36006 check_slash_block(wx+8,wy+wysz);
3568 //layer 1
3569 36006 check_slash_block_layer(wx,wy+wysz-8,1);
3570 36006 check_slash_block_layer(wx,wy+wysz,1);
3571 36006 check_slash_block_layer(wx+8,wy+wysz-8,1);
3572 36006 check_slash_block_layer(wx+8,wy+wysz,1);
3573 //layer 2
3574 36006 check_slash_block_layer(wx,wy+wysz-8,2);
3575 36006 check_slash_block_layer(wx,wy+wysz,2);
3576 36006 check_slash_block_layer(wx+8,wy+wysz-8,2);
3577 36006 check_slash_block_layer(wx+8,wy+wysz,2);
3578 36006 }
3579
3580
2/2
✓ Branch 0 taken 252239 times.
✓ Branch 1 taken 94043 times.
346282 if(dir==left)
3581 {
3582 94043 check_slash_block(wx,wy+8);
3583 94043 check_slash_block(wx+8,wy+8);
3584 //layer 1
3585 94043 check_slash_block_layer(wx,wy+8,1);
3586 94043 check_slash_block_layer(wx+8,wy+8,1);
3587 //layer 2
3588 94043 check_slash_block_layer(wx,wy+8,2);
3589 94043 check_slash_block_layer(wx+8,wy+8,2);
3590 94043 }
3591
3592
2/2
✓ Branch 0 taken 249302 times.
✓ Branch 1 taken 96980 times.
346282 if(dir==right)
3593 {
3594 96980 check_slash_block(wx+wxsz,wy+8);
3595 96980 check_slash_block(wx+wxsz-8,wy+8);
3596 //layer 1
3597 96980 check_slash_block_layer(wx+wxsz,wy+8,1);
3598 96980 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3599 //layer 2
3600 96980 check_slash_block_layer(wx+wxsz,wy+8,2);
3601 96980 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3602 96980 }
3603 346282 }
3604
2/2
✓ Branch 0 taken 13622 times.
✓ Branch 1 taken 11557 times.
25179 else if(attack==wWand)
3605 {
3606
1/2
✓ Branch 0 taken 13622 times.
✗ Branch 1 not taken.
13622 if(attackclk == 5)
3607 {
3608 for(int32_t q=0; q<176; q++)
3609 {
3610 set_bit(screengrid,q,0);
3611 set_bit(screengrid_layer[0],q,0);
3612 set_bit(screengrid_layer[1],q,0);
3613 }
3614
3615 for(dword q = MAXFFCS/8; q > 0; --q)
3616 ffcgrid[q-1] = 0;
3617 }
3618
3619 // cutable blocks
3620
4/4
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 1464 times.
13622 if(dir==up && (x.getInt()&15)==0)
3621 {
3622 1198 check_wand_block(wx,wy);
3623 1198 check_wand_block(wx,wy+8);
3624 1198 }
3625
5/10
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 10960 times.
✓ Branch 2 taken 630 times.
✓ Branch 3 taken 834 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12424 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3626 {
3627 1464 check_wand_block(wx,wy);
3628 1464 check_wand_block(wx,wy+8);
3629 1464 check_wand_block(wx+8,wy);
3630 1464 check_wand_block(wx+8,wy+8);
3631 1464 }
3632
3633
4/4
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 824 times.
✓ Branch 3 taken 1052 times.
13622 if(dir==down && (x.getInt()&15)==0)
3634 {
3635 1052 check_wand_block(wx,wy+wysz-8);
3636 1052 check_wand_block(wx,wy+wysz);
3637 1052 }
3638
5/10
✓ Branch 0 taken 824 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 689 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
12570 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3639 {
3640 824 check_wand_block(wx,wy+wysz-8);
3641 824 check_wand_block(wx,wy+wysz);
3642 824 check_wand_block(wx+8,wy+wysz-8);
3643 824 check_wand_block(wx+8,wy+wysz);
3644 824 }
3645
3646
2/2
✓ Branch 0 taken 8509 times.
✓ Branch 1 taken 5113 times.
13622 if(dir==left)
3647 {
3648 5113 check_wand_block(wx,y+8);
3649 5113 check_wand_block(wx+8,y+8);
3650 5113 }
3651
3652
2/2
✓ Branch 0 taken 9651 times.
✓ Branch 1 taken 3971 times.
13622 if(dir==right)
3653 {
3654 3971 check_wand_block(wx+wxsz,y+8);
3655 3971 check_wand_block(wx+wxsz-8,y+8);
3656 3971 }
3657 13622 }
3658
4/8
✓ Branch 0 taken 11557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10823 times.
✓ Branch 3 taken 734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10823 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11557 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3659 {
3660 // poundable blocks
3661
2/2
✓ Branch 0 taken 129184 times.
✓ Branch 1 taken 734 times.
129918 for(int32_t q=0; q<176; q++)
3662 {
3663 129184 set_bit(screengrid,q,0);
3664 129184 set_bit(screengrid_layer[0],q,0);
3665 129184 set_bit(screengrid_layer[1],q,0);
3666 129184 }
3667
3668
2/2
✓ Branch 0 taken 11744 times.
✓ Branch 1 taken 734 times.
12478 for(dword q = MAXFFCS/8; q > 0; --q)
3669 11744 ffcgrid[q-1] = 0;
3670
3671
4/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 63 times.
734 if(dir==up && (x.getInt()&15)==0)
3672 {
3673 63 check_pound_block(wx,wy);
3674 63 check_pound_block(wx,wy+8);
3675 63 }
3676
3/10
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
671 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3677 {
3678 53 check_pound_block(wx,wy);
3679 53 check_pound_block(wx,wy+8);
3680 53 check_pound_block(wx+8,wy);
3681 53 check_pound_block(wx+8,wy+8);
3682 53 }
3683
3684
4/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 95 times.
734 if(dir==down && (x.getInt()&15)==0)
3685 {
3686 95 check_pound_block(wx,wy+wysz-8);
3687 95 check_pound_block(wx,wy+wysz);
3688 95 }
3689
5/10
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
639 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3690 {
3691 65 check_pound_block(wx,wy+wysz-8);
3692 65 check_pound_block(wx,wy+wysz);
3693 65 check_pound_block(wx+8,wy+wysz-8);
3694 65 check_pound_block(wx+8,wy+wysz);
3695 65 }
3696
3697
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 212 times.
734 if(dir==left)
3698 {
3699 212 check_pound_block(wx,y+8);
3700 212 check_pound_block(wx+8,y+8);
3701 212 }
3702
3703
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 246 times.
734 if(dir==right)
3704 {
3705 246 check_pound_block(wx+wxsz,y+8);
3706 246 check_pound_block(wx+wxsz-8,y+8);
3707 246 }
3708 734 }
3709 10823 else return false;
3710
3711 360638 return true;
3712 7262615 }
3713
3714 1845880 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3715 {
3716
2/2
✓ Branch 0 taken 1844188 times.
✓ Branch 1 taken 1692 times.
1845880 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
3717 {
3718 //zprint("bit off\n");
3719 1844188 return;
3720 }
3721 //keep things inside the screen boundaries
3722 1692 bx=vbound(bx, 0, 255);
3723 1692 by=vbound(by, 0, 176);
3724 1692 int32_t fx=vbound(bx, 0, 255);
3725 1692 int32_t fy=vbound(by, 0, 176);
3726 //first things first
3727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(attack!=wSword)
3728 return;
3729
3730
3/6
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1692 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 176 times.
1868 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3731
3/4
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 1516 times.
1692 || (attackclk>SWORDTAPFRAME && tapping))
3732 return;
3733
3734 //find out which combo row/column the coordinates are in
3735 1692 bx &= 0xF0;
3736 1692 by &= 0xF0;
3737
3738
3739 1692 int32_t flag = MAPFLAGL(layer,bx,by);
3740 1692 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3741 1692 int32_t cid = MAPCOMBOL(layer,bx,by);
3742 1692 int32_t type = combobuf[cid].type;
3743
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3744 type = cNONE;
3745 //zprint("cid is: %d\n", cid);
3746 //zprint("type is: %d\n", type);
3747 1692 int32_t i = (bx>>4) + by;
3748
3749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(i > 175)
3750 return;
3751
3752 1692 bool ignorescreen=false;
3753
3754
2/4
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1692 times.
✗ Branch 3 not taken.
1692 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3755 1692 return;
3756
3757 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3758
3759 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3760 if(isCuttableNextType(type))
3761 {
3762 FFCore.tempScreens[layer]->data[i]++;
3763 }
3764 else
3765 {
3766 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3767 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3768 FFCore.tempScreens[layer]->sflag[i] = 0;
3769 }
3770 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3771 {
3772 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3773 sfx(tmpscr->secretsfx);
3774 }
3775 else if(isCuttableItemType(type))
3776 {
3777 int32_t it = -1;
3778 int32_t thedropset = -1;
3779
3780 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3781 if ( (combobuf[cid].usrflags&cflag2) )
3782 {
3783 if(combobuf[cid].usrflags&cflag11)
3784 it = combobuf[cid].attribytes[1];
3785 else
3786 {
3787 it = select_dropitem(combobuf[cid].attribytes[1]);
3788 thedropset = combobuf[cid].attribytes[1];
3789 }
3790 }
3791 else
3792 {
3793 it = select_dropitem(12);
3794 thedropset = 12;
3795 }
3796 if(it!=-1)
3797 {
3798 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3799 itm->from_dropset = thedropset;
3800 items.add(itm);
3801 }
3802 }
3803
3804 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3805
3806 if(get_qr(qr_MORESOUNDS))
3807 {
3808 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3809 {
3810 if (combobuf[cid].usrflags&cflag3)
3811 {
3812 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3813 }
3814 }
3815 else
3816 {
3817 if (combobuf[cid].usrflags&cflag3)
3818 {
3819 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3820 }
3821 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3822 }
3823 }
3824
3825 spawn_decoration_xy(combobuf[cid], fx, fy);
3826 1845880 }
3827
3828 843254 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3829 {
3830 //keep things inside the screen boundaries
3831 843254 bx=vbound(bx, 0, 255);
3832 843254 by=vbound(by, 0, 176);
3833 843254 int32_t fx=vbound(bx, 0, 255);
3834 843254 int32_t fy=vbound(by, 0, 176);
3835 //first things first
3836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 843254 times.
843254 if(attack!=wSword)
3837 return;
3838
3839
4/6
✓ Branch 0 taken 843254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 843254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 100996 times.
944502 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3840
4/4
✓ Branch 0 taken 839392 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 101248 times.
✓ Branch 3 taken 738144 times.
843254 || (attackclk>SWORDTAPFRAME && tapping))
3841 4114 return;
3842
3843 //find out which combo row/column the coordinates are in
3844 839140 bx &= 0xF0;
3845 839140 by &= 0xF0;
3846
3847 839140 int cid = MAPCOMBO(bx,by);
3848 839140 int cid_ff = MAPFFCOMBO(fx,fy);
3849 839140 int current_ffcombo = getFFCAt(fx,fy);
3850 839140 newcombo const& cmb = combobuf[cid];
3851 839140 newcombo const& cmb_ff = combobuf[cid_ff];
3852 839140 int type = cmb.type;
3853 839140 int type2 = cmb_ff.type;
3854 839140 int flag = MAPFLAG(bx,by);
3855 839140 int flag2 = cmb.flag;
3856 839140 int flag3 = cmb_ff.flag;
3857 839140 int i = (bx>>4) + by;
3858
3859
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 839119 times.
839140 if(i > 175)
3860 21 return;
3861
3862 839119 bool ignorescreen=false;
3863 839119 bool ignoreffc=false;
3864
3865
2/2
✓ Branch 0 taken 830908 times.
✓ Branch 1 taken 8211 times.
839119 if(get_bit(screengrid, i) != 0)
3866 {
3867 8211 ignorescreen = true;
3868 8211 }
3869
2/2
✓ Branch 0 taken 830903 times.
✓ Branch 1 taken 5 times.
830908 else if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
3870 5 ignorescreen = true;
3871
3872
3873
3874
3/4
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 835410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3709 times.
839119 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3875 {
3876 835410 ignoreffc = true;
3877 835410 }
3878
2/2
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 19 times.
3709 else if(cmb_ff.triggerflags[0] & combotriggerONLYGENTRIG)
3879 19 ignoreffc = true;
3880
3881
3/4
✓ Branch 0 taken 833636 times.
✓ Branch 1 taken 5483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 833375 times.
1672494 if(!isCuttableType(type) &&
3882
6/6
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 832207 times.
✓ Branch 2 taken 833375 times.
✓ Branch 3 taken 261 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 833330 times.
833636 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3883 {
3884 833375 ignorescreen = true;
3885 833375 }
3886
3887
3/4
✓ Branch 0 taken 839100 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 839100 times.
1678219 if(!isCuttableType(type2) &&
3888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 839100 times.
839100 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3889 {
3890 839100 ignoreffc = true;
3891 839100 }
3892
3893 839119 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3894
3895
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 806167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
839119 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3896 839119 byte skipsecrets = 0;
3897
3898
2/2
✓ Branch 0 taken 836609 times.
✓ Branch 1 taken 2510 times.
839119 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3899 {
3900
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 44 times.
2510 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
3901 {
3902 2466 skipsecrets = 0;
3903 2466 }
3904 44 else skipsecrets = 1; ;
3905 2510 }
3906
3907
6/6
✓ Branch 0 taken 4196 times.
✓ Branch 1 taken 834923 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 4157 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
839119 if(!ignorescreen && (!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3908 {
3909
5/6
✓ Branch 0 taken 687 times.
✓ Branch 1 taken 3521 times.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 414 times.
4208 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3910 {
3911 414 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3912 414 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3913 414 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3914 414 }
3915
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3790 times.
3794 else if(flag == mfARMOS_SECRET)
3916 {
3917 4 s->data[i] = s->secretcombo[sSTAIRS];
3918 4 s->cset[i] = s->secretcset[sSTAIRS];
3919 4 s->sflag[i] = s->secretflag[sSTAIRS];
3920 4 sfx(tmpscr->secretsfx);
3921 4 }
3922
4/4
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 3523 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 3517 times.
3790 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3923 {
3924
4/4
✓ Branch 0 taken 781 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 530 times.
✓ Branch 3 taken 261 times.
803 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3925 {
3926 530 findentrance(bx,by,mfSWORD+i2,true);
3927 530 }
3928
3929 261 findentrance(bx,by,mfSTRIKE,true);
3930 261 }
3931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3517 else if(((flag2 >= 16)&&(flag2 <= 31)))
3932 {
3933 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3934 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3935 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3936 }
3937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3517 times.
3517 else if(flag2 == mfARMOS_SECRET)
3938 {
3939 s->data[i] = s->secretcombo[sSTAIRS];
3940 s->cset[i] = s->secretcset[sSTAIRS];
3941 s->sflag[i] = s->secretflag[sSTAIRS];
3942 sfx(tmpscr->secretsfx);
3943 }
3944
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3517 times.
3517 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3945 {
3946 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3947 {
3948 findentrance(bx,by,mfSWORD+i2,true);
3949 }
3950
3951 findentrance(bx,by,mfSTRIKE,true);
3952 }
3953 else
3954 {
3955
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 2557 times.
3517 if(isCuttableNextType(type))
3956 {
3957 960 s->data[i]++;
3958 960 }
3959 else
3960 {
3961 2557 s->data[i] = s->undercombo;
3962 2557 s->cset[i] = s->undercset;
3963 2557 s->sflag[i] = 0;
3964 }
3965
3966 //pausenow=true;
3967 }
3968 4196 }
3969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 834935 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
834935 else if(!ignorescreen && skipsecrets)
3970 {
3971 if(isCuttableNextType(type))
3972 {
3973 s->data[i]++;
3974 }
3975 else
3976 {
3977 s->data[i] = s->undercombo;
3978 s->cset[i] = s->undercset;
3979 s->sflag[i] = 0;
3980 }
3981 }
3982
3983
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 839131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 839131 times.
839131 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3984 {
3985 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3986 {
3987 findentrance(bx,by,mfSWORD+i2,true);
3988 }
3989
3990 findentrance(fx,fy,mfSTRIKE,true);
3991 }
3992
1/2
✓ Branch 0 taken 839131 times.
✗ Branch 1 not taken.
839131 else if(!ignoreffc)
3993 {
3994 if(isCuttableNextType(type2))
3995 {
3996 s->ffcs[current_ffcombo].incData(1);
3997 }
3998 else
3999 {
4000 s->ffcs[current_ffcombo].setData(s->undercombo);
4001 s->ffcs[current_ffcombo].cset = s->undercset;
4002 }
4003 }
4004
4005
2/2
✓ Branch 0 taken 834935 times.
✓ Branch 1 taken 4196 times.
839131 if(!ignorescreen)
4006 {
4007
4/4
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 2996 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 955 times.
4196 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4008
4009
8/8
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4134 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 55 times.
4196 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4010 {
4011
4/8
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
62 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4012 62 sfx(tmpscr->secretsfx);
4013 62 }
4014
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 3866 times.
4134 else if(isCuttableItemType(type))
4015 {
4016 3866 int32_t it = -1;
4017 3866 int32_t thedropset = -1;
4018
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 3844 times.
3866 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4019 {
4020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( cmb.usrflags&cflag11 )
4021 {
4022 it = cmb.attribytes[1];
4023 }
4024 else
4025 {
4026 22 it = select_dropitem(cmb.attribytes[1]);
4027 22 thedropset = cmb.attribytes[1];
4028 }
4029 22 }
4030 else
4031 {
4032 3844 it = select_dropitem(12);
4033 3844 thedropset = 12;
4034 }
4035
4036
2/2
✓ Branch 0 taken 2637 times.
✓ Branch 1 taken 1229 times.
3866 if(it!=-1)
4037 {
4038
4/8
✓ Branch 0 taken 1229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1229 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1229 times.
✗ Branch 7 not taken.
1229 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4039 1229 itm->from_dropset = thedropset;
4040 1229 items.add(itm);
4041 1229 }
4042 3866 }
4043
4044 4196 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4045
4046
2/2
✓ Branch 0 taken 4003 times.
✓ Branch 1 taken 193 times.
4196 if(get_qr(qr_MORESOUNDS))
4047 {
4048
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4049 {
4050
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (cmb.usrflags&cflag3)
4051 {
4052 22 sfx(cmb.attribytes[2],int32_t(bx));
4053 22 }
4054 44 }
4055 else
4056 {
4057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (cmb.usrflags&cflag3)
4058 {
4059 sfx(cmb.attribytes[2],int32_t(bx));
4060 }
4061 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4062 }
4063 193 }
4064
4065 4196 spawn_decoration_xy(cmb, fx, fy);
4066 4196 }
4067
4068
1/2
✓ Branch 0 taken 839131 times.
✗ Branch 1 not taken.
839131 if(!ignoreffc)
4069 {
4070 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4071
4072 if(isCuttableItemType(type2))
4073 {
4074 int32_t it=-1;
4075 int32_t thedropset=-1;
4076 if ( (cmb_ff.usrflags&cflag2) )
4077 {
4078 if(cmb_ff.usrflags&cflag11)
4079 it = cmb_ff.attribytes[1];
4080 else
4081 {
4082 it = select_dropitem(cmb_ff.attribytes[1]);
4083 thedropset = cmb_ff.attribytes[1];
4084 }
4085 }
4086 else
4087 {
4088 if(get_qr(qr_HARDCODED_FFC_BUSH_DROPS))
4089 {
4090 int32_t r=zc_oldrand()%100;
4091
4092 if(r<15)
4093 it=iHeart; // 15%
4094 else if(r<35)
4095 it=iRupy; // 20%
4096 }
4097 else
4098 {
4099 it = select_dropitem(12);
4100 thedropset = 12;
4101 }
4102 }
4103
4104 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4105 {
4106 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4107 itm->from_dropset = thedropset;
4108 items.add(itm);
4109 }
4110 }
4111
4112 if(get_qr(qr_MORESOUNDS))
4113 {
4114 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4115 {
4116 if (cmb_ff.usrflags&cflag3)
4117 {
4118 sfx(cmb_ff.attribytes[2],int32_t(bx));
4119 }
4120 }
4121 else
4122 {
4123 if (cmb_ff.usrflags&cflag3)
4124 {
4125 sfx(cmb_ff.attribytes[2],int32_t(bx));
4126 }
4127 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4128 }
4129 }
4130
4131 spawn_decoration_xy(cmb_ff, fx, fy);
4132 }
4133 843266 }
4134
4135 15424540 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4136 {
4137 /*
4138 int32_t par_item = w->parentitem;
4139 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4140 int32_t usewpn = -1;
4141 if ( par_item > -1 )
4142 {
4143 usewpn = itemsbuf[par_item].useweapon;
4144 }
4145 else if ( par_item == -1 && w->ScriptGenerated )
4146 {
4147 usewpn = w->useweapon;
4148 }
4149 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4150
4151 */
4152 15424540 bx=vbound(bx, 0, 255);
4153 15424540 by=vbound(by, 0, 176);
4154 15424540 int32_t cid = MAPCOMBO(bx,by);
4155
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 15222124 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
15424540 switch(w->useweapon)
4156 {
4157 case wArrow:
4158 findentrance(bx,by,mfARROW,true);
4159 findentrance(bx,by,mfSARROW,true);
4160 findentrance(bx,by,mfGARROW,true);
4161 break;
4162 case wBeam:
4163 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4164 break;
4165 case wHookshot:
4166 findentrance(bx,by,mfHOOKSHOT,true);
4167 break;
4168 case wBrang:
4169 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4170 break;
4171 case wMagic:
4172 findentrance(bx,by,mfWANDMAGIC,true);
4173 break;
4174 case wRefMagic:
4175 findentrance(bx,by,mfWANDMAGIC,true);
4176 break;
4177 case wRefBeam:
4178 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4179 break;
4180 //reflected magic needs to happen in mirrors:
4181 //
4182 //findentrance(bx,by,mfREFMAGIC,true)
4183 case wRefFireball:
4184 findentrance(bx,by,mfREFFIREBALL,true);
4185 break;
4186 case wBomb:
4187 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4188 break;
4189
4190 case wSBomb:
4191 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4192 break;
4193
4194 case wFire:
4195 201168 findentrance(bx,by,mfANYFIRE,true);
4196 201168 findentrance(bx,by,mfSTRONGFIRE,true);
4197 201168 findentrance(bx,by,mfMAGICFIRE,true);
4198 /* if we want the weapon to die
4199 if (findentrance(bx,by,mfANYFIRE,true) ) dead = 1;
4200 if (findentrance(bx,by,mfSTRONGFIRE,true) ) dead = 1;
4201 if (findentrance(bx,by,mfMAGICFIRE,true)) dead = 1;
4202 */
4203 201168 break;
4204
4205 case wScript1:
4206 break;
4207 case wScript2:
4208 break;
4209 case wScript3:
4210 break;
4211 case wScript4:
4212 break;
4213 case wScript5:
4214 break;
4215 case wScript6:
4216 break;
4217 case wScript7:
4218 break;
4219 case wScript8:
4220 break;
4221 case wScript9:
4222 break;
4223 case wScript10:
4224 break;
4225 case wIce:
4226 break;
4227 case wCByrna:
4228 break;
4229 case wWhistle:
4230 break;
4231 case wSSparkle:
4232 case wFSparkle:
4233 break;
4234 case wWind:
4235 break;
4236 case wBait:
4237 break;
4238 case wFlame:
4239 case wThrown:
4240 case wBombos:
4241 case wEther:
4242 case wQuake:
4243 case wSwordLA:
4244 case wSword180:
4245 case wStomp:
4246 break;
4247 case wSword:
4248 case wWand:
4249 //case wCandle:
4250 case wHSHandle:
4251 case wLitBomb:
4252 case wLitSBomb:
4253 1248 break;
4254 15222124 default: break;
4255
4256 }
4257 15424540 }
4258
4259 30849080 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4260 {
4261
4262
2/2
✓ Branch 0 taken 98990 times.
✓ Branch 1 taken 30750090 times.
30849080 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4263 {
4264 //zprint("bit off\n");
4265 30750090 return;
4266 }
4267 //keep things inside the screen boundaries
4268 98990 bx=vbound(bx, 0, 255);
4269 98990 by=vbound(by, 0, 176);
4270 98990 int32_t fx=vbound(bx, 0, 255);
4271 98990 int32_t fy=vbound(by, 0, 176);
4272 //first things first
4273
1/2
✓ Branch 0 taken 98990 times.
✗ Branch 1 not taken.
98990 if(w->useweapon != wSword)
4274 98990 return;
4275
4276 //find out which combo row/column the coordinates are in
4277 bx &= 0xF0;
4278 by &= 0xF0;
4279
4280
4281 int32_t flag = MAPFLAGL(layer,bx,by);
4282 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4283 int32_t cid = MAPCOMBOL(layer,bx,by);
4284 int32_t type = combobuf[cid].type;
4285 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4286 type = cNONE;
4287 //zprint("cid is: %d\n", cid);
4288 //zprint("type is: %d\n", type);
4289 int32_t i = (bx>>4) + by;
4290
4291 if(i > 175)
4292 return;
4293
4294 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4295 {
4296 return;
4297 //ignorescreen = true;
4298 //zprint("ignoring\n");
4299 }
4300
4301 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4302
4303 {
4304 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4305 if(isCuttableNextType(type) || isCuttableNextType(type))
4306 {
4307 FFCore.tempScreens[layer]->data[i]++;
4308 }
4309 else
4310 {
4311 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4312 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4313 FFCore.tempScreens[layer]->sflag[i] = 0;
4314 }
4315 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4316 {
4317 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4318 sfx(tmpscr->secretsfx);
4319 }
4320 else if(isCuttableItemType(type))
4321 {
4322 int32_t it = -1;
4323 int32_t thedropset = -1;
4324
4325 if ( (combobuf[cid].usrflags&cflag2) )
4326 {
4327 if(combobuf[cid].usrflags&cflag11)
4328 it = combobuf[cid].attribytes[1];
4329 else
4330 {
4331 it = select_dropitem(combobuf[cid].attribytes[1]);
4332 thedropset = combobuf[cid].attribytes[1];
4333 }
4334 }
4335 else
4336 {
4337 it = select_dropitem(12);
4338 thedropset = 12;
4339 }
4340
4341 if(it!=-1)
4342 {
4343 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4344 itm->from_dropset = thedropset;
4345 items.add(itm);
4346 }
4347 }
4348
4349 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4350
4351 if(get_qr(qr_MORESOUNDS))
4352 {
4353 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4354 {
4355 if (combobuf[cid].usrflags&cflag3)
4356 {
4357 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4358 }
4359 }
4360 else
4361 {
4362 if (combobuf[cid].usrflags&cflag3)
4363 {
4364 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4365 }
4366 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4367 }
4368 }
4369
4370 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4371 if(decotype > 3) decotype = 0;
4372 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4373 switch(decotype)
4374 {
4375 case -2: break; //nothing
4376 case -1:
4377 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4378 break;
4379 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4380 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4381 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4382 }
4383
4384 }
4385
4386 30849080 }
4387
4388 15424540 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4389 {
4390 /*
4391 int32_t par_item = w->parentitem;
4392 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4393 int32_t usewpn = -1;
4394 if ( par_item > -1 )
4395 {
4396 usewpn = itemsbuf[par_item].useweapon;
4397 }
4398 else if ( par_item == -1 && w->ScriptGenerated )
4399 {
4400 usewpn = w->useweapon;
4401 }
4402 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4403 */
4404
4405
4406 //keep things inside the screen boundaries
4407 15424540 bx=vbound(bx, 0, 255);
4408 15424540 by=vbound(by, 0, 176);
4409 15424540 int32_t fx=vbound(bx, 0, 255);
4410 15424540 int32_t fy=vbound(by, 0, 176);
4411 15424540 int32_t cid = MAPCOMBO(bx,by);
4412
4413 //find out which combo row/column the coordinates are in
4414 15424540 bx &= 0xF0;
4415 15424540 by &= 0xF0;
4416
4417 15424540 int32_t type = COMBOTYPE(bx,by);
4418 15424540 int32_t type2 = FFCOMBOTYPE(fx,fy);
4419 15424540 int32_t flag = MAPFLAG(bx,by);
4420 15424540 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4421 15424540 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4422
2/2
✓ Branch 0 taken 15424326 times.
✓ Branch 1 taken 214 times.
15424540 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4423 214 type = cNONE;
4424 15424540 byte dontignore = 0;
4425 15424540 byte dontignoreffc = 0;
4426
4427
4/4
✓ Branch 0 taken 281222 times.
✓ Branch 1 taken 15143318 times.
✓ Branch 2 taken 280923 times.
✓ Branch 3 taken 299 times.
15424540 if (isCuttableType(type) && MatchComboTrigger(w, combobuf.data(), cid))
4428 {
4429 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4430 299 dontignore = 1;
4431 299 }
4432
4433 /*to-do, ffcs
4434 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4435 {
4436 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4437 dontignoreffc = 1;
4438 }*/
4439
4/4
✓ Branch 0 taken 15423292 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 15422993 times.
✓ Branch 3 taken 299 times.
15424540 if(w->useweapon != wSword && !dontignore) return;
4440
4441
4442 1547 int32_t i = (bx>>4) + by;
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4444
4445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4446 return;
4447
4448 1547 bool ignorescreen=false;
4449 1547 bool ignoreffc=false;
4450
4451
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4452 {
4453 ignorescreen = true; dontignore = 0;
4454 }
4455
4456 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4457
4458
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4459 {
4460 1545 ignoreffc = true;
4461 1545 }
4462
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4463 type2 = cNONE;
4464
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4465
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4466 {
4467 1248 ignorescreen = true;
4468 1248 }
4469
4470
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4472 {
4473 1547 ignoreffc = true;
4474 1547 }
4475
4476 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4477
4478
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4479 1547 byte skipsecrets = 0;
4480
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4481 {
4482
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4483 {
4484 249 skipsecrets = 0;
4485 249 }
4486 else skipsecrets = 1;
4487 249 }
4488
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 1547 times.
1547 if((!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4489 {
4490
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2795 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4491 {
4492 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4493 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4494 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4495 }
4496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4497 {
4498 s->data[i] = s->secretcombo[sSTAIRS];
4499 s->cset[i] = s->secretcset[sSTAIRS];
4500 s->sflag[i] = s->secretflag[sSTAIRS];
4501 sfx(tmpscr->secretsfx);
4502 }
4503
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4504 {
4505 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4506 {
4507 findentrance(bx,by,mfSWORD+i2,true);
4508 }
4509
4510 findentrance(bx,by,mfSTRIKE,true);
4511 }
4512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4513 {
4514 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4515 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4516 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4517 }
4518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4519 {
4520 s->data[i] = s->secretcombo[sSTAIRS];
4521 s->cset[i] = s->secretcset[sSTAIRS];
4522 s->sflag[i] = s->secretflag[sSTAIRS];
4523 sfx(tmpscr->secretsfx);
4524 }
4525
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4526 {
4527 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4528 {
4529 findentrance(bx,by,mfSWORD+i2,true);
4530 }
4531
4532 findentrance(bx,by,mfSTRIKE,true);
4533 }
4534 else
4535 {
4536
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4537 {
4538 249 s->data[i]++;
4539 249 }
4540 else
4541 {
4542 50 s->data[i] = s->undercombo;
4543 50 s->cset[i] = s->undercset;
4544 50 s->sflag[i] = 0;
4545 }
4546
4547 //pausenow=true;
4548 }
4549 299 }
4550
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4551 {
4552 if(isCuttableNextType(type))
4553 {
4554 s->data[i]++;
4555 }
4556 else
4557 {
4558 s->data[i] = s->undercombo;
4559 s->cset[i] = s->undercset;
4560 s->sflag[i] = 0;
4561 }
4562 }
4563
4564
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4565 {
4566 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4567 {
4568 findentrance(bx,by,mfSWORD+i2,true);
4569 }
4570
4571 findentrance(fx,fy,mfSTRIKE,true);
4572 }
4573
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4574 {
4575 if(isCuttableNextType(type2))
4576 {
4577 s->ffcs[current_ffcombo].incData(1);
4578 }
4579 else
4580 {
4581 s->ffcs[current_ffcombo].setData(s->undercombo);
4582 s->ffcs[current_ffcombo].cset = s->undercset;
4583 }
4584 }
4585
4586
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4587 {
4588
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4589
4590
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4591 {
4592 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4593 sfx(tmpscr->secretsfx);
4594 }
4595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4596 {
4597 299 int32_t it = -1;
4598 299 int32_t thedropset = -1;
4599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4600 {
4601 if ( combobuf[cid].usrflags&cflag11 )
4602 {
4603 it = combobuf[cid].attribytes[1];
4604 }
4605 else
4606 {
4607 it = select_dropitem(combobuf[cid].attribytes[1]);
4608 thedropset = combobuf[cid].attribytes[1];
4609 }
4610 }
4611 else
4612 {
4613 299 it = select_dropitem(12);
4614 299 thedropset = 12;
4615 }
4616
4617
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4618 {
4619
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4620 99 itm->from_dropset = thedropset;
4621 99 items.add(itm);
4622 99 }
4623 299 }
4624
4625
4626 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4627
4628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_qr(qr_MORESOUNDS))
4629 {
4630
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4631 {
4632 if (combobuf[cid].usrflags&cflag3)
4633 {
4634 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4635 }
4636 }
4637 else
4638 {
4639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4640 {
4641 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4642 }
4643 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4644 }
4645 299 }
4646
4647
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4648
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4649
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4650
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4651 {
4652 case -2: break; //nothing
4653 case -1:
4654 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4655 break;
4656
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4657
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4658 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4659 }
4660 299 }
4661
4662
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4663 {
4664 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4665
4666 if(isCuttableItemType(type2))
4667 {
4668 int32_t it=-1;
4669 int32_t thedropset=-1;
4670 if ( (combobuf[cid].usrflags&cflag2) )
4671 {
4672 if(combobuf[cid].usrflags&cflag11)
4673 it = combobuf[cid].attribytes[1];
4674 else
4675 {
4676 it = select_dropitem(combobuf[cid].attribytes[1]);
4677 thedropset = combobuf[cid].attribytes[1];
4678 }
4679 }
4680 else
4681 {
4682 int32_t r=zc_oldrand()%100;
4683
4684 if(r<15)
4685 {
4686 it=iHeart; // 15%
4687 }
4688 else if(r<35)
4689 {
4690 it=iRupy; // 20%
4691 }
4692 }
4693
4694 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4695 {
4696 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4697 itm->from_dropset = thedropset;
4698 items.add(itm);
4699 }
4700 }
4701
4702 if(get_qr(qr_MORESOUNDS))
4703 {
4704 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4705 {
4706 if (combobuf[cid].usrflags&cflag3)
4707 {
4708 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4709 }
4710 }
4711 else
4712 {
4713 if (combobuf[cid].usrflags&cflag3)
4714 {
4715 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4716 }
4717 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4718 }
4719 }
4720
4721 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4722 if(decotype > 3) decotype = 0;
4723 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4724 switch(decotype)
4725 {
4726 case -2: break; //nothing
4727 case -1:
4728 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4729 break;
4730 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4731 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4732 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4733 }
4734 }
4735 15424540 }
4736
4737 15424540 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4738 {
4739 /*
4740 int32_t par_item = w->parentitem;
4741 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4742 int32_t usewpn = -1;
4743 if ( par_item > -1 )
4744 {
4745 usewpn = itemsbuf[par_item].useweapon;
4746 }
4747 else if ( par_item == -1 && w->ScriptGenerated )
4748 {
4749 usewpn = w->useweapon;
4750 }
4751 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4752 */
4753
4754 15424540 byte dontignore = 0;
4755 15424540 byte dontignoreffc = 0;
4756
4757
4758
4759
4760
4761 //keep things inside the screen boundaries
4762 15424540 bx=vbound(bx, 0, 255);
4763 15424540 by=vbound(by, 0, 176);
4764 15424540 int32_t fx=vbound(bx, 0, 255);
4765 15424540 int32_t fy=vbound(by, 0, 176);
4766 15424540 int32_t cid = MAPCOMBO(bx,by);
4767
4768 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4769
3/4
✓ Branch 0 taken 15424540 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 15423881 times.
15424540 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf.data(), cid)) return;
4770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659 times.
659 if ( MatchComboTrigger (w, combobuf.data(), cid) ) dontignore = 1;
4771
4772 //first things first
4773
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4774
4775 //find out which combo row/column the coordinates are in
4776 659 bx &= 0xF0;
4777 659 by &= 0xF0;
4778
4779 659 int32_t flag = MAPFLAG(bx,by);
4780 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4781 659 int32_t flag3=0;
4782 659 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4783 659 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4784 659 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4785 659 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4786
4787
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4788 flag3=mfWAND;
4789
4790
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4791 flag3=mfSTRIKE;
4792
4793 659 int32_t i = (bx>>4) + by;
4794
4795
6/12
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 659 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 659 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 659 times.
659 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4796 659 return;
4797
4798 if(i > 175)
4799 return;
4800
4801 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4802
4803 //findentrance(bx,by,mfWAND,true);
4804 //findentrance(bx,by,mfSTRIKE,true);
4805 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4806 {
4807 if(flag3==mfWAND||flag3==mfSTRIKE)
4808 {
4809 findentrance(fx,fy,mfWAND,true);
4810 findentrance(fx,fy,mfSTRIKE,true);
4811 }
4812 }
4813
4814 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4815
4816 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4817 15424540 }
4818
4819 void HeroClass::check_slash_block(weapon *w)
4820 {
4821 //first things
4822
4823 int32_t par_item = w->parentitem;
4824 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4825 int32_t usewpn = -1;
4826 if ( par_item > -1 )
4827 {
4828 usewpn = itemsbuf[par_item].useweapon;
4829 }
4830 else if ( par_item == -1 && w->ScriptGenerated )
4831 {
4832 usewpn = w->useweapon;
4833 }
4834 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4835 if(usewpn != wSword) return;
4836
4837
4838 int32_t bx = 0, by = 0;
4839 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
4840 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
4841 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
4842 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
4843 //keep things inside the screen boundaries
4844 bx=vbound(bx, 0, 255);
4845 by=vbound(by, 0, 176);
4846 int32_t fx=vbound(bx, 0, 255);
4847 int32_t fy=vbound(by, 0, 176);
4848
4849 int32_t cid = MAPCOMBO(bx,by);
4850
4851 //find out which combo row/column the coordinates are in
4852 bx &= 0xF0;
4853 by &= 0xF0;
4854
4855 int32_t type = COMBOTYPE(bx,by);
4856 int32_t type2 = FFCOMBOTYPE(fx,fy);
4857 int32_t flag = MAPFLAG(bx,by);
4858 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4859 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4860 int32_t i = (bx>>4) + by;
4861
4862 if(i > 175)
4863 {
4864 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
4865 return;
4866 }
4867
4868 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4869 type = cNONE;
4870 bool ignorescreen=false;
4871 bool ignoreffc=false;
4872
4873 if(get_bit(screengrid, i) != 0)
4874 {
4875 ignorescreen = true;
4876 }
4877
4878 int32_t current_ffcombo = getFFCAt(fx,fy);
4879
4880 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4881 {
4882 ignoreffc = true;
4883 }
4884 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4885 type2 = cNONE;
4886 if(!isCuttableType(type) &&
4887 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4888 {
4889 ignorescreen = true;
4890 }
4891
4892 if(!isCuttableType(type2) &&
4893 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4894 {
4895 ignoreffc = true;
4896 }
4897
4898 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4899
4900 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
4901
4902 if(!ignorescreen)
4903 {
4904 if((flag >= 16)&&(flag <= 31))
4905 {
4906 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4907 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4908 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4909 }
4910 else if(flag == mfARMOS_SECRET)
4911 {
4912 s->data[i] = s->secretcombo[sSTAIRS];
4913 s->cset[i] = s->secretcset[sSTAIRS];
4914 s->sflag[i] = s->secretflag[sSTAIRS];
4915 sfx(tmpscr->secretsfx);
4916 }
4917 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4918 {
4919 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4920 {
4921 findentrance(bx,by,mfSWORD+i2,true);
4922 }
4923
4924 findentrance(bx,by,mfSTRIKE,true);
4925 }
4926 else if(((flag2 >= 16)&&(flag2 <= 31)))
4927 {
4928 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4929 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4930 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4931 }
4932 else if(flag2 == mfARMOS_SECRET)
4933 {
4934 s->data[i] = s->secretcombo[sSTAIRS];
4935 s->cset[i] = s->secretcset[sSTAIRS];
4936 s->sflag[i] = s->secretflag[sSTAIRS];
4937 sfx(tmpscr->secretsfx);
4938 }
4939 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4940 {
4941 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4942 {
4943 findentrance(bx,by,mfSWORD+i2,true);
4944 }
4945
4946 findentrance(bx,by,mfSTRIKE,true);
4947 }
4948 else
4949 {
4950 if(isCuttableNextType(type))
4951 {
4952 s->data[i]++;
4953 }
4954 else
4955 {
4956 s->data[i] = s->undercombo;
4957 s->cset[i] = s->undercset;
4958 s->sflag[i] = 0;
4959 }
4960
4961 //pausenow=true;
4962 }
4963 }
4964
4965 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4966 {
4967 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4968 {
4969 findentrance(bx,by,mfSWORD+i2,true);
4970 }
4971
4972 findentrance(fx,fy,mfSTRIKE,true);
4973 }
4974 else if(!ignoreffc)
4975 {
4976 if(isCuttableNextType(type2))
4977 {
4978 s->ffcs[current_ffcombo].incData(1);
4979 }
4980 else
4981 {
4982 s->ffcs[current_ffcombo].setData(s->undercombo);
4983 s->ffcs[current_ffcombo].cset = s->undercset;
4984 }
4985 }
4986
4987 if(!ignorescreen)
4988 {
4989 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4990
4991 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4992 {
4993 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4994 sfx(tmpscr->secretsfx);
4995 }
4996 else if(isCuttableItemType(type))
4997 {
4998 int32_t it = -1;
4999 int32_t thedropset = -1;
5000 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5001 {
5002 if ( combobuf[cid].usrflags&cflag11 )
5003 {
5004 it = combobuf[cid].attribytes[1];
5005 }
5006 else
5007 {
5008 it = select_dropitem(combobuf[cid].attribytes[1]);
5009 thedropset = combobuf[cid].attribytes[1];
5010 }
5011 }
5012 else
5013 {
5014 it = select_dropitem(12);
5015 thedropset = 12;
5016 }
5017
5018 if(it!=-1)
5019 {
5020 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5021 itm->from_dropset = thedropset;
5022 items.add(itm);
5023 }
5024 }
5025
5026 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5027
5028 if(get_qr(qr_MORESOUNDS))
5029 {
5030 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5031 {
5032 if (combobuf[cid].usrflags&cflag3)
5033 {
5034 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5035 }
5036 }
5037 else
5038 {
5039 if (combobuf[cid].usrflags&cflag3)
5040 {
5041 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5042 }
5043 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5044 }
5045 }
5046
5047 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5048 if(decotype > 3) decotype = 0;
5049 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5050 switch(decotype)
5051 {
5052 case -2: break; //nothing
5053 case -1:
5054 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5055 break;
5056 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5057 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5058 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5059 }
5060 }
5061
5062 if(!ignoreffc)
5063 {
5064 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5065
5066 if(isCuttableItemType(type2))
5067 {
5068 int32_t it=-1;
5069 int32_t thedropset = -1;
5070 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5071 {
5072 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5073 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5074 else
5075 {
5076 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5077 it = select_dropitem(thedropset);
5078 }
5079 }
5080 else
5081 {
5082 it = select_dropitem(12);
5083 thedropset = 12;
5084 }
5085
5086 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5087 {
5088 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5089 itm->from_dropset = thedropset;
5090 items.add(itm);
5091 }
5092 }
5093
5094 if(get_qr(qr_MORESOUNDS))
5095 {
5096 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5097 {
5098 if (combobuf[cid].usrflags&cflag3)
5099 {
5100 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5101 }
5102 }
5103 else
5104 {
5105 if (combobuf[cid].usrflags&cflag3)
5106 {
5107 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5108 }
5109 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5110 }
5111 }
5112
5113 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5114 if(decotype > 3) decotype = 0;
5115 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5116 switch(decotype)
5117 {
5118 case -2: break; //nothing
5119 case -1:
5120 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5121 break;
5122 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5123 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5124 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5125 }
5126 }
5127 }
5128
5129 //TODO: Boomerang that cuts bushes. -L
5130 /*void HeroClass::slash_bush()
5131 {
5132
5133 }*/
5134
5135 31820 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5136 {
5137 //keep things inside the screen boundaries
5138 31820 bx=vbound(bx, 0, 255);
5139 31820 by=vbound(by, 0, 176);
5140 31820 int32_t fx=vbound(bx, 0, 255);
5141 31820 int32_t fy=vbound(by, 0, 176);
5142 31820 int32_t cid = MAPCOMBO(bx,by);
5143
5144 //first things first
5145
2/4
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31820 times.
31820 if(z>8||fakez>8) return;
5146
5147 //find out which combo row/column the coordinates are in
5148 31820 bx &= 0xF0;
5149 31820 by &= 0xF0;
5150
5151 31820 int32_t flag = MAPFLAG(bx,by);
5152 31820 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5153 31820 int32_t flag3=0;
5154 31820 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5155 31820 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5156 31820 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5157 31820 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5158
5159
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5160 flag3=mfWAND;
5161
5162
4/8
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31820 times.
31820 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5163 flag3=mfSTRIKE;
5164
5165 31820 int32_t i = (bx>>4) + by;
5166
5167
6/12
✓ Branch 0 taken 31820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31820 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31820 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31820 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 31820 times.
✗ Branch 11 not taken.
31820 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5168 31820 return;
5169
5170 if(i > 175)
5171 return;
5172
5173 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5174
5175 //findentrance(bx,by,mfWAND,true);
5176 //findentrance(bx,by,mfSTRIKE,true);
5177 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5178 {
5179 if(flag3==mfWAND||flag3==mfSTRIKE)
5180 {
5181 findentrance(fx,fy,mfWAND,true);
5182 findentrance(fx,fy,mfSTRIKE,true);
5183 }
5184 }
5185
5186 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5187 31820 }
5188
5189 1704 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5190 {
5191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1704 if(w && w->no_triggers()) return;
5192
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1704 if(w && w->id == wHammer && getHammerState() < 3)
5193 return;
5194
1/2
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
1704 if(get_qr(qr_POUNDLAYERS1AND2))
5195 {
5196 check_pound_block_layer(bx,by,1,w);
5197 check_pound_block_layer(bx,by,2,w);
5198 }
5199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 auto* grid = w ? w->wscreengrid : screengrid;
5200 //keep things inside the screen boundaries
5201 1704 bx=vbound(bx, 0, 255);
5202 1704 by=vbound(by, 0, 176);
5203 1704 int32_t fx=vbound(bx, 0, 255);
5204 1704 int32_t fy=vbound(by, 0, 176);
5205 1704 int32_t cid = MAPCOMBO(bx,by);
5206
5207 //first things first
5208
2/4
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1704 times.
1704 if(z>8||fakez>8) return;
5209
5210 //find out which combo row/column the coordinates are in
5211 1704 bx &= 0xF0;
5212 1704 by &= 0xF0;
5213
5214 1704 int32_t type = COMBOTYPE(bx,by);
5215 1704 int32_t type2 = FFCOMBOTYPE(fx,fy);
5216 1704 int32_t flag = MAPFLAG(bx,by);
5217 1704 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5218 1704 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5219 1704 int32_t i = (bx>>4) + by;
5220
5221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1704 times.
1704 if(i > 175)
5222 return;
5223
5224 1704 bool ignorescreen=false;
5225 1704 bool ignoreffc=false;
5226 1704 bool pound=false;
5227
5228
6/10
✓ Branch 0 taken 1646 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 1646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1646 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1646 times.
1704 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5229 1646 ignorescreen = true; // Affect only FFCs
5230
5231
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 27 times.
1704 if(get_bit(grid, i) != 0)
5232 27 ignorescreen = true;
5233
5234 1704 int32_t current_ffcombo = getFFCAt(fx,fy);
5235
5236
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1703 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1704 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5237 1703 ignoreffc = true;
5238
5239
3/6
✓ Branch 0 taken 1704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1704 times.
1704 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5240 1704 ignoreffc = true;
5241
5242
3/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1704 if(ignorescreen && ignoreffc) // Nothing to do.
5243 1654 return;
5244
5245 50 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5246
5247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5248 {
5249
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5250 {
5251 findentrance(bx,by,mfHAMMER,true);
5252 findentrance(bx,by,mfSTRIKE,true);
5253 }
5254
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5255 {
5256 findentrance(bx,by,mfHAMMER,true);
5257 findentrance(bx,by,mfSTRIKE,true);
5258 }
5259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag >= 16)&&(flag <= 31))
5260 {
5261 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5262 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5263 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5264 }
5265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag == mfARMOS_SECRET)
5266 {
5267 s->data[i] = s->secretcombo[sSTAIRS];
5268 s->cset[i] = s->secretcset[sSTAIRS];
5269 s->sflag[i] = s->secretflag[sSTAIRS];
5270 sfx(tmpscr->secretsfx);
5271 }
5272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if((flag2 >= 16)&&(flag2 <= 31))
5273 {
5274 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5275 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5276 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5277 }
5278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 else if(flag2 == mfARMOS_SECRET)
5279 {
5280 s->data[i] = s->secretcombo[sSTAIRS];
5281 s->cset[i] = s->secretcset[sSTAIRS];
5282 s->sflag[i] = s->secretflag[sSTAIRS];
5283 sfx(tmpscr->secretsfx);
5284 }
5285 50 else pound = true;
5286 50 }
5287
5288
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5289 {
5290 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5291 {
5292 findentrance(fx,fy,mfHAMMER,true);
5293 findentrance(fx,fy,mfSTRIKE,true);
5294 }
5295 else
5296 {
5297 s->ffcs[current_ffcombo].incData(1);
5298 }
5299 }
5300
5301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(!ignorescreen)
5302 {
5303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(pound)
5304 50 s->data[i]+=1;
5305
5306 50 set_bit(grid,i,1);
5307
5308
2/8
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5309 {
5310 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5311 sfx(tmpscr->secretsfx);
5312 }
5313
5314
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
50 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5315 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5316
5317 50 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5318 50 }
5319
5320
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(!ignoreffc)
5321 {
5322 set_bit(ffcgrid,current_ffcombo,1);
5323
5324 if(type2==cPOUND && get_qr(qr_MORESOUNDS))
5325 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5326 }
5327
5328 50 return;
5329 1704 }
5330
5331 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5332 {
5333 if(lyr < 1 || lyr > 2) return; //sanity
5334 //keep things inside the screen boundaries
5335 bx=vbound(bx, 0, 255);
5336 by=vbound(by, 0, 176);
5337 int32_t cid = MAPCOMBOL(lyr,bx,by);
5338 newcombo const& scr_cmb = combobuf[cid];
5339 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5340
5341 //first things first
5342 if(z>8||fakez>8) return;
5343
5344 //find out which combo row/column the coordinates are in
5345 bx &= 0xF0;
5346 by &= 0xF0;
5347
5348 int32_t type = scr_cmb.type;
5349 int32_t flag = MAPFLAGL(lyr,bx,by);
5350 int32_t flag2 = scr_cmb.flag;
5351 int32_t i = (bx>>4) + by;
5352
5353 if(i > 175)
5354 return;
5355
5356 bool pound=false;
5357
5358 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5359 return;
5360
5361 if(get_bit(grid, i) != 0)
5362 return;
5363
5364 mapscr *s = FFCore.tempScreens[lyr];
5365
5366 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5367 {
5368 findentrance(bx,by,mfHAMMER,true);
5369 findentrance(bx,by,mfSTRIKE,true);
5370 }
5371 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5372 {
5373 findentrance(bx,by,mfHAMMER,true);
5374 findentrance(bx,by,mfSTRIKE,true);
5375 }
5376 else if((flag >= 16)&&(flag <= 31))
5377 {
5378 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5379 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5380 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5381 }
5382 else if(flag == mfARMOS_SECRET)
5383 {
5384 s->data[i] = s->secretcombo[sSTAIRS];
5385 s->cset[i] = s->secretcset[sSTAIRS];
5386 s->sflag[i] = s->secretflag[sSTAIRS];
5387 sfx(tmpscr->secretsfx);
5388 }
5389 else if((flag2 >= 16)&&(flag2 <= 31))
5390 {
5391 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5392 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5393 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5394 }
5395 else if(flag2 == mfARMOS_SECRET)
5396 {
5397 s->data[i] = s->secretcombo[sSTAIRS];
5398 s->cset[i] = s->secretcset[sSTAIRS];
5399 s->sflag[i] = s->secretflag[sSTAIRS];
5400 sfx(tmpscr->secretsfx);
5401 }
5402 else pound = true;
5403
5404 if(pound)
5405 s->data[i]+=1;
5406
5407 set_bit(grid,i,1);
5408
5409 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5410 {
5411 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5412 sfx(tmpscr->secretsfx);
5413 }
5414
5415 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5416 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5417
5418 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5419 }
5420
5421 void HeroClass::check_wand_block(weapon *w)
5422 {
5423
5424 int32_t par_item = w->parentitem;
5425 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5426 int32_t usewpn = -1;
5427 if ( par_item > -1 )
5428 {
5429 usewpn = itemsbuf[par_item].useweapon;
5430 }
5431 else if ( par_item == -1 && w->ScriptGenerated )
5432 {
5433 usewpn = w->useweapon;
5434 }
5435 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5436 if(usewpn != wWand) return;
5437
5438
5439 int32_t bx = 0, by = 0;
5440 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5441 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5442
5443 //keep things inside the screen boundaries
5444 bx=vbound(bx, 0, 255);
5445 by=vbound(by, 0, 176);
5446 int32_t fx=vbound(bx, 0, 255);
5447 int32_t fy=vbound(by, 0, 176);
5448 int32_t cid = MAPCOMBO(bx,by);
5449 //first things first
5450 if(z>8||fakez>8) return;
5451
5452 //find out which combo row/column the coordinates are in
5453 bx &= 0xF0;
5454 by &= 0xF0;
5455
5456 int32_t flag = MAPFLAG(bx,by);
5457 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5458 int32_t flag3=0;
5459 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5460 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5461 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5462 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5463
5464 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5465 flag3=mfWAND;
5466
5467 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5468 flag3=mfSTRIKE;
5469
5470 int32_t i = (bx>>4) + by;
5471
5472 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5473 return;
5474
5475 if(i > 175)
5476 return;
5477
5478 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5479
5480 //findentrance(bx,by,mfWAND,true);
5481 //findentrance(bx,by,mfSTRIKE,true);
5482 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5483 {
5484 if(flag3==mfWAND||flag3==mfSTRIKE)
5485 {
5486 findentrance(fx,fy,mfWAND,true);
5487 findentrance(fx,fy,mfSTRIKE,true);
5488 }
5489 }
5490
5491 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5492 }
5493
5494 //defend results should match defence types.
5495 //RETURN VALUES:
5496 // -1 iGNORE WEAPON
5497 // 0 No effects
5498 // 1 Effects, weapon is not ignored or removed
5499 7011 int32_t HeroClass::defend(weapon *w)
5500 {
5501 7011 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5502
1/25
✓ Branch 0 taken 7011 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
7011 switch(def)
5503 {
5504 7011 case edNORMAL: return 1;
5505 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5506 {
5507 w->power *= 0.5;
5508 return 1;
5509 }
5510 case edQUARTDAMAGE:
5511 {
5512 w->power *= 0.25;
5513 return 1;
5514 }
5515 case edSTUNONLY:
5516 {
5517 setStunClock(120);
5518 return 1;
5519 }
5520 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5521 {
5522 if (w->power > 0)
5523 {
5524 setStunClock(120);
5525 return 1;
5526 }
5527 else
5528 {
5529 sfx(WAV_CHINK,pan(int32_t(x)));
5530 w->dead = 0;
5531 return -1;
5532 }
5533 }
5534 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5535 {
5536 if (w->power > 0)
5537 {
5538 setStunClock(120);
5539 return 1;
5540 }
5541 else
5542 {
5543 return -1;
5544 }
5545 }
5546 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5547 {
5548 if (w->power < 1)
5549 {
5550 sfx(WAV_CHINK,pan(int32_t(x)));
5551 w->dead = 0;
5552 return -1;
5553 }
5554 else
5555 {
5556 return 1;
5557 }
5558 }
5559 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5560 {
5561 if (w->power < 2)
5562 {
5563 sfx(WAV_CHINK,pan(int32_t(x)));
5564 w->dead = 0;
5565 return -1;
5566 }
5567 else
5568 {
5569 return 1;
5570 }
5571 }
5572 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5573 {
5574 if (w->power < 4)
5575 {
5576 sfx(WAV_CHINK,pan(int32_t(x)));
5577 w->dead = 0;
5578 return -1;
5579 }
5580 else
5581 {
5582 return 1;
5583 }
5584 }
5585 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5586 {
5587 if (w->power < 6)
5588 {
5589 sfx(WAV_CHINK,pan(int32_t(x)));
5590 w->dead = 0;
5591 return -1;
5592 }
5593 else
5594 {
5595 return 1;
5596 }
5597 }
5598 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5599 {
5600 if (w->power < 8)
5601 {
5602 sfx(WAV_CHINK,pan(int32_t(x)));
5603 w->dead = 0;
5604 return -1;
5605 }
5606 else
5607 {
5608 return 1;
5609 }
5610 }
5611 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5612 {
5613 sfx(WAV_CHINK,pan(int32_t(x)));
5614 w->dead = 0;
5615 return -1;
5616 }
5617 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5618 {
5619 if (w->power < 1)
5620 {
5621 return -1;
5622 }
5623 else return 1;
5624 }
5625 case edIGNORE: // : IMPLEMENTED : Do Nothing
5626 {
5627 return -1;
5628 }
5629 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5630 {
5631 game->set_life(0);
5632 return 1;
5633 }
5634 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5635 {
5636 if (w->power < 10)
5637 {
5638 sfx(WAV_CHINK,pan(int32_t(x)));
5639 w->dead = 0;
5640 return -1;
5641 }
5642 else
5643 {
5644 return 1;
5645 }
5646 }
5647 case ed2x: // : IMPLEMENTED : Double damage.
5648 {
5649 w->power *= 2;
5650 return 1;
5651 }
5652 case ed3x: // : IMPLEMENTED : Triple Damage.
5653 {
5654 w->power *= 3;
5655 return 1;
5656 }
5657 case ed4x: // : IMPLEMENTED : 4x damage.
5658 {
5659 w->power *= 4;
5660 return 1;
5661 }
5662 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5663 {
5664 //sfx(WAV_HEAL,pan(int32_t(x)));
5665 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5666 w->dead = 0;
5667 return -1;
5668 }
5669
5670 case edFREEZE: return 1; //Not IMPLEMENTED
5671
5672 case edLEVELDAMAGE: //Damage * item level
5673 {
5674 w->power *= w->family_level;
5675 return 1;
5676 }
5677 case edLEVELREDUCTION: //Damage / item level
5678 {
5679 if ( w->family_level > 0 )
5680 {
5681 w->power /= w->family_level;
5682 }
5683 else w->power = 0;
5684 return 1;
5685 }
5686
5687 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5688 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5689 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5690 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5691
5692 //edSHOCK, //buzz blob
5693
5694
5695 case edBREAKSHIELD: //destroy the player's present shield
5696 {
5697 w->power = 0;
5698 w->dead = 0;
5699 int32_t itemid = getCurrentShield();
5700 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5701 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5702 game->set_item(itemid, false);
5703 //Remove Hero's shield
5704 return -1;
5705 }
5706
5707
5708
5709 default: return 0;
5710 }
5711 7011 }
5712 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5713 {
5714 return al_map_rgba(0,0,255,opacity);
5715 }
5716 6792 int32_t HeroClass::compareDir(int32_t other)
5717 {
5718
5/6
✓ Branch 0 taken 6787 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6787 times.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 6716 times.
6792 if(other != NORMAL_DIR(other))
5719 76 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5720 6716 int32_t ret = 0;
5721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6716 times.
6716 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5722
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1406 times.
✓ Branch 2 taken 1100 times.
✓ Branch 3 taken 2095 times.
✓ Branch 4 taken 2115 times.
6716 switch(d)
5723 {
5724 case up:
5725 {
5726
3/3
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 530 times.
1406 switch(X_DIR(other))
5727 {
5728 case left:
5729 537 ret |= CMPDIR_RIGHT;
5730 537 break;
5731 case right:
5732 530 ret |= CMPDIR_LEFT;
5733 530 break;
5734 }
5735
3/3
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 1005 times.
1406 switch(Y_DIR(other))
5736 {
5737 case up:
5738 234 ret |= CMPDIR_BACK;
5739 234 break;
5740 case down:
5741 1005 ret |= CMPDIR_FRONT;
5742 1005 break;
5743 }
5744 1406 break;
5745 }
5746 case down:
5747 {
5748
3/3
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 346 times.
✓ Branch 2 taken 423 times.
1100 switch(X_DIR(other))
5749 {
5750 case left:
5751 346 ret |= CMPDIR_LEFT;
5752 346 break;
5753 case right:
5754 423 ret |= CMPDIR_RIGHT;
5755 423 break;
5756 }
5757
3/3
✓ Branch 0 taken 151 times.
✓ Branch 1 taken 757 times.
✓ Branch 2 taken 192 times.
1100 switch(Y_DIR(other))
5758 {
5759 case up:
5760 757 ret |= CMPDIR_FRONT;
5761 757 break;
5762 case down:
5763 192 ret |= CMPDIR_BACK;
5764 192 break;
5765 }
5766 1100 break;
5767 }
5768 case left:
5769 {
5770
3/3
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 303 times.
✓ Branch 2 taken 1690 times.
2095 switch(X_DIR(other))
5771 {
5772 case left:
5773 303 ret |= CMPDIR_BACK;
5774 303 break;
5775 case right:
5776 1690 ret |= CMPDIR_FRONT;
5777 1690 break;
5778 }
5779
3/3
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 627 times.
✓ Branch 2 taken 707 times.
2095 switch(Y_DIR(other))
5780 {
5781 case up:
5782 627 ret |= CMPDIR_LEFT;
5783 627 break;
5784 case down:
5785 707 ret |= CMPDIR_RIGHT;
5786 707 break;
5787 }
5788 2095 break;
5789 }
5790 case right:
5791 {
5792
3/3
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 1739 times.
✓ Branch 2 taken 273 times.
2115 switch(X_DIR(other))
5793 {
5794 case left:
5795 1739 ret |= CMPDIR_FRONT;
5796 1739 break;
5797 case right:
5798 273 ret |= CMPDIR_BACK;
5799 273 break;
5800 }
5801
3/3
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 526 times.
✓ Branch 2 taken 769 times.
2115 switch(Y_DIR(other))
5802 {
5803 case up:
5804 526 ret |= CMPDIR_RIGHT;
5805 526 break;
5806 case down:
5807 769 ret |= CMPDIR_LEFT;
5808 769 break;
5809 }
5810 2115 break;
5811 }
5812 }
5813 6716 return ret;
5814 6792 }
5815
5816 6792 bool compareShield(int32_t cmpdir, itemdata const& shield)
5817 {
5818
1/2
✓ Branch 0 taken 6792 times.
✗ Branch 1 not taken.
6792 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
5819
1/2
✓ Branch 0 taken 6792 times.
✗ Branch 1 not taken.
6792 if(standard) //Use standard sides, either a passive shield, or a held active shield
5820 {
5821
3/4
✓ Branch 0 taken 5191 times.
✓ Branch 1 taken 1601 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5191 times.
6792 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
5822 5191 return true;
5823
3/4
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
1601 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
5824 return true;
5825
3/4
✓ Branch 0 taken 637 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
1601 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
5826 return true;
5827
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 926 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 675 times.
1601 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
5828 return true;
5829 1601 }
5830 else //Active Shield that is NOT held down
5831 {
5832 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
5833 return true;
5834 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
5835 return true;
5836 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
5837 return true;
5838 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
5839 return true;
5840 }
5841 1601 return false;
5842 6792 }
5843
5844 6504414 int32_t HeroClass::EwpnHit()
5845 {
5846
2/2
✓ Branch 0 taken 6501298 times.
✓ Branch 1 taken 4715005 times.
11216303 for(int32_t i=0; i<Ewpns.Count(); i++)
5847 {
5848
2/2
✓ Branch 0 taken 4707994 times.
✓ Branch 1 taken 7011 times.
4715005 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
5849 {
5850 7011 weapon *ew = (weapon*)(Ewpns.spr(i));
5851
5852
3/6
✓ Branch 0 taken 7011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7011 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7011 times.
7011 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
5853 break;
5854
5855 7011 int32_t stompid = current_item_id(itype_stompboots);
5856
5857
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 7005 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
7011 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
5858
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
5859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
5860 {
5861 itemdata const& stomp = itemsbuf[stompid];
5862 bool remove = false;
5863 switch(ew->id)
5864 {
5865 case ewFireball2:
5866 case ewFireball:
5867 if(ew->type & 1) //Boss fireball
5868 {
5869 if(stomp.misc2 & (shFIREBALL2))
5870 remove = true;
5871 }
5872 else
5873 {
5874 if(stomp.misc2 & (shFIREBALL))
5875 remove = true;
5876 }
5877
5878 break;
5879
5880 case ewMagic:
5881 if((stomp.misc2 & shMAGIC))
5882 remove = true;
5883 break;
5884
5885 case ewSword:
5886 if((stomp.misc2 & shSWORD))
5887 remove = true;
5888
5889 break;
5890
5891 case ewFlame:
5892 if((stomp.misc2 & shFLAME))
5893 remove = true;
5894
5895 break;
5896
5897 case ewRock:
5898 if((stomp.misc2 & shROCK))
5899 remove = true;
5900
5901 break;
5902
5903 case ewArrow:
5904 if((stomp.misc2 & shARROW))
5905 remove = true;
5906
5907 break;
5908
5909 case ewBrang:
5910 if((stomp.misc2 & shBRANG))
5911 remove = true;
5912
5913 break;
5914
5915 default: // Just throw the script weapons in here...
5916 if(ew->id>=wScript1 && ew->id<=wScript10)
5917 {
5918 if((stomp.misc2 & shSCRIPT))
5919 remove = true;
5920 }
5921
5922 break;
5923 }
5924 if (remove)
5925 {
5926 ew->onhit(false);
5927 sfx(WAV_CHINK,pan(x.getInt()));
5928 continue;
5929 }
5930 }
5931
5932 7011 int32_t defresult = defend(ew);
5933
1/2
✓ Branch 0 taken 7011 times.
✗ Branch 1 not taken.
7011 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
5934
5935
2/2
✓ Branch 0 taken 7010 times.
✓ Branch 1 taken 1 times.
7011 if(ew->id==ewWind)
5936 {
5937 1 xofs=1000;
5938 1 action=freeze; FFCore.setHeroAction(freeze);
5939 1 ew->misc=999; // in enemy wind
5940 1 attackclk=0;
5941 1 return -1;
5942 }
5943
5944
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6998 times.
7010 switch(ew->id)
5945 {
5946 case ewLitBomb:
5947 case ewBomb:
5948 case ewLitSBomb:
5949 case ewSBomb:
5950 12 return i;
5951 }
5952
5953 6998 int32_t itemid = getCurrentShield(false);
5954
4/6
✓ Branch 0 taken 6790 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 6790 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6790 times.
6998 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
5955 208 return i;
5956 6790 itemdata const& shield = itemsbuf[itemid];
5957 6790 bool allow_inactive = (shield.flags & ITEM_FLAG9);
5958 6790 auto cmpdir = compareDir(ew->dir);
5959 6790 bool hitshield = compareShield(cmpdir, shield);
5960
5961
12/20
✓ Branch 0 taken 6790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6790 times.
✓ Branch 4 taken 5482 times.
✓ Branch 5 taken 1308 times.
✓ Branch 6 taken 5482 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5454 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 5454 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5454 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5454 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 5454 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5454 times.
✗ Branch 19 not taken.
6790 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
5962 1336 return i;
5963
5964
2/2
✓ Branch 0 taken 4263 times.
✓ Branch 1 taken 1191 times.
5454 if(!hitshield)
5965 1191 return i;
5966
5967 4263 paymagiccost(itemid);
5968
5969 4263 bool reflect = false;
5970
5971
8/8
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 357 times.
✓ Branch 5 taken 261 times.
✓ Branch 6 taken 252 times.
✓ Branch 7 taken 221 times.
4263 switch(ew->id)
5972 {
5973 case ewFireball2:
5974 case ewFireball:
5975
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 2184 times.
2340 if(ew->type & 1) //Boss fireball
5976 {
5977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 if(!(shield.misc1 & (shFIREBALL2)))
5978 156 return i;
5979
5980 reflect = ((shield.misc2 & shFIREBALL2) != 0);
5981 }
5982 else
5983 {
5984
2/2
✓ Branch 0 taken 2084 times.
✓ Branch 1 taken 100 times.
2184 if(!(shield.misc1 & (shFIREBALL)))
5985 100 return i;
5986
5987 2084 reflect = ((shield.misc2 & shFIREBALL) != 0);
5988 }
5989
5990 2084 break;
5991
5992 case ewMagic:
5993
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 33 times.
557 if(!(shield.misc1 & shMAGIC))
5994 33 return i;
5995
5996 524 reflect = ((shield.misc2 & shMAGIC) != 0);
5997 524 break;
5998
5999 case ewSword:
6000
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 26 times.
273 if(!(shield.misc1 & shSWORD))
6001 26 return i;
6002
6003 247 reflect = ((shield.misc2 & shSWORD) != 0);
6004 247 break;
6005
6006 case ewFlame:
6007
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 51 times.
357 if(!(shield.misc1 & shFLAME))
6008 51 return i;
6009
6010 306 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6011 306 break;
6012
6013 case ewRock:
6014
1/2
✓ Branch 0 taken 261 times.
✗ Branch 1 not taken.
261 if(!(shield.misc1 & shROCK))
6015 return i;
6016
6017 261 reflect = (shield.misc2 & shROCK);
6018 261 break;
6019
6020 case ewArrow:
6021
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(!(shield.misc1 & shARROW))
6022 return i;
6023
6024 252 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6025 252 break;
6026
6027 case ewBrang:
6028
1/2
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
221 if(!(shield.misc1 & shBRANG))
6029 return i;
6030
6031 221 break;
6032
6033 default: // Just throw the script weapons in here...
6034
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(ew->id>=wScript1 && ew->id<=wScript10)
6035 {
6036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!(shield.misc1 & shSCRIPT))
6037 2 return i;
6038
6039 reflect = ((shield.misc2 & shSCRIPT) != 0);
6040 }
6041
6042 break;
6043 }
6044
6045
3/4
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 2798 times.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
3895 if(reflect && (ew->unblockable&WPNUNB_REFL))
6046 reflect = false;
6047
3/4
✓ Branch 0 taken 2798 times.
✓ Branch 1 taken 1097 times.
✓ Branch 2 taken 2798 times.
✗ Branch 3 not taken.
3895 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6048 return i;
6049
6050 3895 int32_t oldid = ew->id;
6051 3895 ew->onhit(false, reflect ? 2 : 1, dir);
6052
6053
2/2
✓ Branch 0 taken 2798 times.
✓ Branch 1 taken 1097 times.
3895 if(ew->id != oldid) // changed type from ewX to wX
6054 {
6055 // ew->power*=game->get_hero_dmgmult();
6056 1097 Lwpns.add(ew);
6057 1097 Ewpns.remove(ew);
6058 1097 ew->isLWeapon = true; //Make sure this gets set everywhere!
6059 1097 }
6060
6061
2/2
✓ Branch 0 taken 3556 times.
✓ Branch 1 taken 339 times.
3895 if(ew->id==wRefMagic)
6062 {
6063 339 ew->ignoreHero=true;
6064 339 ew->ignorecombo=-1;
6065 339 }
6066
6067 3895 sfx(shield.usesound,pan(x.getInt()));
6068 3895 }
6069 4711889 }
6070
6071 6501298 return -1;
6072 6504414 }
6073
6074 6504416 int32_t HeroClass::LwpnHit() //only here to check magic hits
6075 {
6076
2/2
✓ Branch 0 taken 6387880 times.
✓ Branch 1 taken 2674001 times.
9061881 for(int32_t i=0; i<Lwpns.Count(); i++)
6077
2/2
✓ Branch 0 taken 2557465 times.
✓ Branch 1 taken 116536 times.
2674001 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6078 {
6079 116536 weapon *lw = (weapon*)(Lwpns.spr(i));
6080
6081
2/2
✓ Branch 0 taken 113299 times.
✓ Branch 1 taken 3237 times.
116536 if((lw->ignoreHero)==true)
6082 3237 break;
6083
6084
5/8
✓ Branch 0 taken 113299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113297 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 113297 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 113297 times.
113299 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6085 2 int32_t itemid = getCurrentShield(false);
6086
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6087 return i;
6088 2 itemdata const& shield = itemsbuf[itemid];
6089 2 auto cmpdir = compareDir(lw->dir);
6090 2 bool hitshield = compareShield(cmpdir, shield);
6091 2 bool reflect = false;
6092
6093
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 switch(lw->id)
6094 {
6095 case wRefFireball:
6096 if(itemid<0)
6097 return i;
6098
6099 if(lw->type & 1) //Boss fireball
6100 return i;
6101
6102 if(!(shield.misc1 & (shFIREBALL)))
6103 return i;
6104
6105 reflect = ((shield.misc2 & shFIREBALL) != 0);
6106 break;
6107
6108 case wRefMagic:
6109
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemid<0)
6110 return i;
6111
6112
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shMAGIC))
6113 return i;
6114
6115 2 reflect = ((shield.misc2 & shMAGIC) != 0);
6116 2 break;
6117
6118 case wRefBeam:
6119 if(itemid<0)
6120 return i;
6121
6122 if(!(shield.misc1 & shSWORD))
6123 return i;
6124
6125 reflect = ((shield.misc2 & shSWORD) != 0);
6126 break;
6127
6128 case wRefRock:
6129 if(itemid<0)
6130 return i;
6131
6132 if(!(shield.misc1 & shROCK))
6133 return i;
6134
6135 reflect = (shield.misc2 & shROCK);
6136 break;
6137
6138 default:
6139 return -1;
6140 }
6141
6142 2 bool allow_inactive = (shield.flags & ITEM_FLAG9);
6143
10/20
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
2 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6144 return i;
6145
6146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!hitshield)
6147 2 return i;
6148
6149 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6150
6151 paymagiccost(itemid);
6152
6153 lw->onhit(false, 1+reflect, dir);
6154 lw->ignoreHero=true;
6155 lw->ignorecombo=-1;
6156 sfx(shield.usesound,pan(x.getInt()));
6157 }
6158
6159 6391117 return -1;
6160 6504416 }
6161
6162 11140119 void HeroClass::checkhit()
6163 {
6164
2/2
✓ Branch 0 taken 3877246 times.
✓ Branch 1 taken 7262873 times.
11140119 if(checkhero==true)
6165 {
6166
2/2
✓ Branch 0 taken 6909403 times.
✓ Branch 1 taken 353470 times.
7262873 if(hclk>0)
6167 {
6168 353470 --hclk;
6169 353470 }
6170
6171
1/2
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
7262873 if(DivineProtectionShieldClk>0)
6172 {
6173 --DivineProtectionShieldClk;
6174
6175 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6176 {
6177 stop_sfx(itemsbuf[div_prot_item].usesound);
6178 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6179 div_prot_item = -1;
6180 }
6181 else if(get_qr(qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6182 {
6183 stop_sfx(itemsbuf[div_prot_item].usesound);
6184 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6185 }
6186 }
6187 7262873 }
6188
6189
4/4
✓ Branch 0 taken 7195476 times.
✓ Branch 1 taken 3944643 times.
✓ Branch 2 taken 7191416 times.
✓ Branch 3 taken 4060 times.
11140119 if(hclk<39 && action==gothit)
6190 {
6191 4060 action=none; FFCore.setHeroAction(none);
6192 4060 }
6193
6194
5/6
✓ Branch 0 taken 7195476 times.
✓ Branch 1 taken 3944643 times.
✓ Branch 2 taken 7195424 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7195424 times.
11140119 if(hclk<39 && (action==swimhit || action == sideswimhit))
6195 {
6196 52 SetSwim();
6197 52 }
6198
6199
4/4
✓ Branch 0 taken 59943 times.
✓ Branch 1 taken 11080176 times.
✓ Branch 2 taken 16532 times.
✓ Branch 3 taken 43411 times.
11140119 if(hclk>=40 && action==gothit)
6200 {
6201 43411 int val = check_pitslide();
6202
4/4
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 43118 times.
✓ Branch 2 taken 43539 times.
✓ Branch 3 taken 43246 times.
43411 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6203 {
6204
2/2
✓ Branch 0 taken 174156 times.
✓ Branch 1 taken 43539 times.
217695 for(int32_t i=0; i<4; i++)
6205 {
6206
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38300 times.
✓ Branch 2 taken 42128 times.
✓ Branch 3 taken 45172 times.
✓ Branch 4 taken 48556 times.
174156 switch(hitdir)
6207 {
6208 case up:
6209
6/6
✓ Branch 0 taken 2458 times.
✓ Branch 1 taken 35842 times.
✓ Branch 2 taken 2930 times.
✓ Branch 3 taken 32912 times.
✓ Branch 4 taken 2486 times.
✓ Branch 5 taken 35814 times.
38300 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6210 {
6211 2486 action=none; FFCore.setHeroAction(none);
6212 2486 }
6213
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 35810 times.
35814 else if (val == -1) --y;
6214
6215 38300 break;
6216
6217 case down:
6218
6/6
✓ Branch 0 taken 3361 times.
✓ Branch 1 taken 38767 times.
✓ Branch 2 taken 3306 times.
✓ Branch 3 taken 35461 times.
✓ Branch 4 taken 3399 times.
✓ Branch 5 taken 38729 times.
42128 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6219 {
6220 3399 action=none; FFCore.setHeroAction(none);
6221 3399 }
6222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38729 times.
38729 else if (val == -1) ++y;
6223
6224 42128 break;
6225
6226 case left:
6227
7/8
✓ Branch 0 taken 43605 times.
✓ Branch 1 taken 1567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43605 times.
✓ Branch 4 taken 1281 times.
✓ Branch 5 taken 42324 times.
✓ Branch 6 taken 1571 times.
✓ Branch 7 taken 43601 times.
45172 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6228 {
6229 1571 action=none; FFCore.setHeroAction(none);
6230 1571 }
6231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43601 times.
43601 else if (val == -1) --x;
6232
6233 45172 break;
6234
6235 case right:
6236
8/8
✓ Branch 0 taken 46633 times.
✓ Branch 1 taken 1923 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 46629 times.
✓ Branch 4 taken 1147 times.
✓ Branch 5 taken 45482 times.
✓ Branch 6 taken 1943 times.
✓ Branch 7 taken 46613 times.
48556 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6237 {
6238 1943 action=none; FFCore.setHeroAction(none);
6239 1943 }
6240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46613 times.
46613 else if (val == -1) ++x;
6241
6242 48556 break;
6243 }
6244 174156 }
6245 43539 }
6246 43667 }
6247
6248
18/20
✓ Branch 0 taken 6916619 times.
✓ Branch 1 taken 4223756 times.
✓ Branch 2 taken 6916420 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 6906720 times.
✓ Branch 5 taken 9700 times.
✓ Branch 6 taken 6906080 times.
✓ Branch 7 taken 640 times.
✓ Branch 8 taken 6906080 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6906080 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6905932 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 6901710 times.
✓ Branch 15 taken 4222 times.
✓ Branch 16 taken 5089 times.
✓ Branch 17 taken 6896621 times.
✓ Branch 18 taken 4575099 times.
✓ Branch 19 taken 4580188 times.
11140375 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6249 {
6250 8813764 return;
6251 }
6252
6253
2/2
✓ Branch 0 taken 7463298 times.
✓ Branch 1 taken 6896516 times.
14359814 for(int32_t i=0; i<Lwpns.Count(); i++)
6254 {
6255 7463298 sprite *s = Lwpns.spr(i);
6256 7463298 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6257 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6258 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6259
13/14
✓ Branch 0 taken 606944 times.
✓ Branch 1 taken 6856354 times.
✓ Branch 2 taken 2276166 times.
✓ Branch 3 taken 4580188 times.
✓ Branch 4 taken 2276166 times.
✓ Branch 5 taken 2304022 times.
✓ Branch 6 taken 2251570 times.
✓ Branch 7 taken 52452 times.
✓ Branch 8 taken 2251570 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 82996 times.
✓ Branch 11 taken 2168574 times.
✓ Branch 12 taken 38957 times.
✓ Branch 13 taken 44039 times.
7463298 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6260 {
6261
9/10
✓ Branch 0 taken 2138030 times.
✓ Branch 1 taken 74583 times.
✓ Branch 2 taken 74234 times.
✓ Branch 3 taken 349 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 349 times.
✓ Branch 6 taken 360 times.
✓ Branch 7 taken 73874 times.
✓ Branch 8 taken 2211904 times.
✓ Branch 9 taken 25 times.
2212638 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6262
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
709 (itemid < 0 || itemsbuf[itemid].family!=itype_divinefire))
6263 {
6264 25 std::vector<int32_t> &ev = FFCore.eventData;
6265 25 ev.clear();
6266 25 ev.push_back(lwpn_dp(i)*10000);
6267 25 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6268 25 ev.push_back(0);
6269 25 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6270 25 ev.push_back(48*10000);
6271 25 ev.push_back(ZSD_LWPN*10000);
6272 25 ev.push_back(s->getUID());
6273 25 ev.push_back(ZSD_NONE*10000);
6274 25 ev.push_back(0);
6275
6276 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6277 25 int32_t dmg = ev[0]/10000;
6278 25 bool nullhit = ev[2] != 0;
6279
6280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) {ev.clear(); return;}
6281
6282 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6283 25 ev[0] = ringpower(dmg)*10000;
6284
6285 25 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6286 25 dmg = ev[0]/10000;
6287 25 int32_t hdir = ev[1]/10000;
6288 25 nullhit = ev[2] != 0;
6289 25 bool divineprot = ev[3] != 0;
6290 25 int32_t iframes = ev[4] / 10000;
6291 25 ev.clear();
6292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(nullhit) return;
6293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!divineprot)
6294 {
6295
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 game->set_life(zc_max(game->get_life()-dmg,0));
6296
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (!get_qr(qr_BROKENHITBY))
6297 {
6298 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6299 if (get_qr(qr_BROKENHITBY))
6300 {
6301 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6302 }
6303 else
6304 {
6305
6306 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6307 }
6308 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6309 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6310 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6311 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6312 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6313 }
6314 25 }
6315
6316 25 hitdir = hdir;
6317
6318
3/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
25 if (action != rafting && action != freeze && action != sideswimfreeze)
6319 {
6320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (IsSideSwim())
6321 {
6322 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6323 }
6324
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 else if (action == swimming || hopclk == 0xFF)
6325 {
6326 action=swimhit; FFCore.setHeroAction(swimhit);
6327 }
6328 else
6329 {
6330 25 action=gothit; FFCore.setHeroAction(gothit);
6331 }
6332 25 }
6333
6334
5/8
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
25 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6335 {
6336 5 spins = charging = attackclk = 0;
6337 5 attack=none;
6338 5 tapping = false;
6339 5 }
6340
6341 25 hclk=iframes;
6342 25 sfx(getHurtSFX(),pan(x.getInt()));
6343 25 return;
6344 }
6345 2211904 }
6346
6347 // check enemy weapons true, 1, -1
6348 //
6349
2/2
✓ Branch 0 taken 2865304 times.
✓ Branch 1 taken 17781 times.
2910257 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6350 {
6351
6/6
✓ Branch 0 taken 1717 times.
✓ Branch 1 taken 16064 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 100 times.
17781 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6352 {
6353
1/2
✓ Branch 0 taken 16164 times.
✗ Branch 1 not taken.
16164 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6354 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6355 16164 itemid = vbound(itemid, 0, MAXITEMS-1);
6356
6357
2/2
✓ Branch 0 taken 16160 times.
✓ Branch 1 taken 1039 times.
17199 for(int32_t j=0; j<Ewpns.Count(); j++)
6358 {
6359 1039 sprite *t = Ewpns.spr(j);
6360
6361
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6362 {
6363 4 bool reflect = false;
6364 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6365
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6366 {
6367 case ewBrang:
6368 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6369
6370 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6371 goto killweapon;
6372
6373 case ewArrow:
6374 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6375
6376 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6377 goto killweapon;
6378
6379 case ewRock:
6380 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6381
6382 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6383 goto killweapon;
6384
6385 case ewFireball2:
6386 case ewFireball:
6387 {
6388 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6389
6390 if(!(itemsbuf[itemid].misc3 & mask)) break;
6391
6392 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6393 goto killweapon;
6394 }
6395
6396 case ewSword:
6397 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6398
6399 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6400 goto killweapon;
6401
6402 case wRefMagic:
6403 case ewMagic:
6404 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6405
6406 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6407 goto killweapon;
6408
6409 case wScript1:
6410 case wScript2:
6411 case wScript3:
6412 case wScript4:
6413 case wScript5:
6414 case wScript6:
6415 case wScript7:
6416 case wScript8:
6417 case wScript9:
6418 case wScript10:
6419 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6420
6421 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6422 goto killweapon;
6423
6424 case ewLitBomb:
6425 case ewLitSBomb:
6426 killweapon:
6427 ((weapon*)s)->dead=1;
6428 weapon *ew = ((weapon*)t);
6429 int32_t oldid = ew->id;
6430 ew->onhit(true, reflect ? 2 : 1, s->dir);
6431
6432 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6433 {
6434 Lwpns.add(ew);
6435 Ewpns.remove(ew);
6436 ew->isLWeapon = true; //Make sure this gets set everywhere!
6437 }
6438
6439 if(ew->id==wRefMagic)
6440 {
6441 ew->ignoreHero=true;
6442 ew->ignorecombo=-1;
6443 }
6444
6445 break;
6446 }
6447
6448 4 break;
6449 }
6450 1035 }
6451 16164 }
6452 17781 }
6453
6454
6/6
✓ Branch 0 taken 2033790 times.
✓ Branch 1 taken 849295 times.
✓ Branch 2 taken 606944 times.
✓ Branch 3 taken 1426846 times.
✓ Branch 4 taken 32722 times.
✓ Branch 5 taken 574222 times.
2883085 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6455 {
6456
6/8
✓ Branch 0 taken 874234 times.
✓ Branch 1 taken 7783 times.
✓ Branch 2 taken 7781 times.
✓ Branch 3 taken 874236 times.
✓ Branch 4 taken 7781 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7781 times.
882017 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && (scriptcoldet&1) && !fallclk)
6457 {
6458 7781 weapon* w = (weapon*)s;
6459 7781 bool didhit = s->hit(this);
6460
2/2
✓ Branch 0 taken 7768 times.
✓ Branch 1 taken 13 times.
7781 if(didhit)
6461 {
6462 13 std::vector<int32_t> &ev = FFCore.eventData;
6463 13 ev.clear();
6464
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6465 13 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6466 13 ev.push_back(0);
6467 13 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6468 13 ev.push_back(48*10000);
6469 13 ev.push_back(ZSD_LWPN*10000);
6470 13 ev.push_back(s->getUID());
6471 13 ev.push_back(ZSD_NONE*10000);
6472 13 ev.push_back(0);
6473
6474 13 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6475 13 int32_t dmg = ev[0]/10000;
6476 13 bool nullhit = ev[2] != 0;
6477
6478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(nullhit) {ev.clear(); return;}
6479
6480 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6481 13 ev[0] = ringpower(dmg)*10000;
6482
6483 13 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6484 13 dmg = ev[0]/10000;
6485 13 int32_t hdir = ev[1]/10000;
6486 13 nullhit = ev[2] != 0;
6487 13 bool divineprot = ev[3] != 0;
6488 13 int32_t iframes = ev[4] / 10000;
6489 13 ev.clear();
6490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(nullhit) return;
6491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!divineprot)
6492 {
6493
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6494
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (!get_qr(qr_BROKENHITBY))
6495 {
6496 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6497 if (get_qr(qr_BROKENHITBY))
6498 {
6499 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6500 }
6501 else
6502 {
6503
6504 sethitHeroUID(HIT_BY_LWEAPON_UID,((weapon*)(Lwpns.spr(i)))->getScriptUID());
6505 }
6506 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,((weapon*)(Lwpns.spr(i)))->getUID());
6507 sethitHeroUID(HIT_BY_LWEAPON_TYPE, ((weapon*)(Lwpns.spr(i)))->id);
6508 if (((weapon*)(Lwpns.spr(i)))->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, ((weapon*)(Lwpns.spr(i)))->parentitem);
6509 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6510 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[((weapon*)(Lwpns.spr(i)))->parentitem].family);
6511 }
6512 13 }
6513
6514 13 hitdir = hdir;
6515
6516
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
13 if (action != rafting && action != freeze && action != sideswimfreeze)
6517 {
6518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (IsSideSwim())
6519 {
6520 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6521 }
6522
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 else if (action == swimming || hopclk == 0xFF)
6523 {
6524 action=swimhit; FFCore.setHeroAction(swimhit);
6525 }
6526 else
6527 {
6528 13 action=gothit; FFCore.setHeroAction(gothit);
6529 }
6530 13 }
6531
6532
4/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
13 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6533 {
6534 spins = charging = attackclk = 0;
6535 attack=none;
6536 tapping = false;
6537 }
6538
6539 13 hclk=iframes;
6540 13 sfx(getHurtSFX(),pan(x.getInt()));
6541 13 return;
6542 }
6543 7768 }
6544 882004 }
6545
6546
7/8
✓ Branch 0 taken 2883072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 2876838 times.
✓ Branch 4 taken 6167 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 2883005 times.
✓ Branch 7 taken 67 times.
2883072 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6547 {
6548 67 std::vector<int32_t> &ev = FFCore.eventData;
6549 67 ev.clear();
6550 67 ev.push_back(0);
6551 67 ev.push_back(s->dir*10000);
6552 67 ev.push_back(0);
6553 67 ev.push_back(0);
6554 67 ev.push_back(ZSD_LWPN*10000);
6555 67 ev.push_back(s->getUID());
6556 67 ev.push_back(ZSD_NONE*10000);
6557 67 ev.push_back(0);
6558
6559 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6560 67 bool nullhit = ev[2] != 0;
6561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) {ev.clear(); return;}
6562
6563 67 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6564 67 int32_t hdir = ev[1]/10000;
6565 67 nullhit = ev[2] != 0;
6566 67 ev.clear();
6567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(nullhit) return;
6568
6569 67 reset_hookshot();
6570 67 xofs=1000;
6571 67 action=inwind; FFCore.setHeroAction(inwind);
6572 67 dir=s->dir=hdir;
6573 67 spins = charging = attackclk = 0;
6574
6575 // In case Hero used two whistles in a row, summoning two whirlwinds,
6576 // check which whistle's whirlwind picked him up so the correct
6577 // warp ring will be used
6578 67 int32_t whistle=((weapon*)s)->parentitem;
6579
6580
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6581 67 whistleitem=whistle;
6582
6583 67 return;
6584 }
6585 2883005 }
6586
6587
6/8
✓ Branch 0 taken 6827749 times.
✓ Branch 1 taken 68767 times.
✓ Branch 2 taken 6664190 times.
✓ Branch 3 taken 163559 times.
✓ Branch 4 taken 6664190 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6664190 times.
13560706 if(action==rafting || action==freeze || action==sideswimfreeze ||
6588
4/8
✓ Branch 0 taken 6664190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6664190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6664190 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6664190 times.
✗ Branch 7 not taken.
6664190 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6589 232326 return;
6590
6591 6664190 int32_t hit2 = -1;
6592 6664190 do
6593 {
6594
2/2
✓ Branch 0 taken 874993 times.
✓ Branch 1 taken 5797891 times.
6672884 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6595 5797891 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6596
6597
2/2
✓ Branch 0 taken 6655598 times.
✓ Branch 1 taken 17286 times.
6672884 if(hit2!=-1)
6598 {
6599
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 8592 times.
17286 if (hithero(hit2) == 0) return;
6600 8694 }
6601
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 6655598 times.
6664292 } while (hit2 != -1);
6602
6/6
✓ Branch 0 taken 6509723 times.
✓ Branch 1 taken 145875 times.
✓ Branch 2 taken 6504869 times.
✓ Branch 3 taken 4854 times.
✓ Branch 4 taken 453 times.
✓ Branch 5 taken 6504416 times.
6655598 if (superman || !(scriptcoldet&1) || fallclk) return;
6603 6504416 hit2 = LwpnHit();
6604
6605
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6504414 times.
6504416 if(hit2!=-1)
6606 {
6607 2 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6608 2 std::vector<int32_t> &ev = FFCore.eventData;
6609 2 ev.clear();
6610 2 ev.push_back((lwpn_dp(hit2)*10000));
6611 2 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6612 2 ev.push_back(0);
6613 2 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6614 2 ev.push_back(48*10000);
6615 2 ev.push_back(ZSD_LWPN*10000);
6616 2 ev.push_back(lwpnspr->getUID());
6617 2 ev.push_back(ZSD_NONE*10000);
6618 2 ev.push_back(0);
6619
6620 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6621 2 int32_t dmg = ev[0]/10000;
6622 2 bool nullhit = ev[2] != 0;
6623
6624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) {ev.clear(); return;}
6625
6626 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6627 2 ev[0] = ringpower(dmg)*10000;
6628
6629 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6630 2 dmg = ev[0]/10000;
6631 2 int32_t hdir = ev[1]/10000;
6632 2 nullhit = ev[2] != 0;
6633 2 bool divineprot = ev[3] != 0;
6634 2 int32_t iframes = ev[4] / 10000;
6635 2 ev.clear();
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) return;
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!divineprot)
6638 {
6639
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_max(game->get_life()-dmg,0));
6640 2 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6641
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (get_qr(qr_BROKENHITBY))
6642 {
6643 2 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6644 2 }
6645 else
6646 {
6647
6648 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getScriptUID());
6649 }
6650 2 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,lwpnspr->getUID());
6651 2 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
6652
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
6653 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6654 2 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].family);
6655 2 }
6656
6657 2 hitdir = hdir;
6658 2 lwpnspr->onhit(false);
6659
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (IsSideSwim())
6661 {
6662 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6663 }
6664
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 else if(action==swimming || hopclk==0xFF)
6665 {
6666 action=swimhit; FFCore.setHeroAction(swimhit);
6667 }
6668 else
6669 {
6670 2 action=gothit; FFCore.setHeroAction(gothit);
6671 }
6672
6673 2 hclk=iframes;
6674
6675
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6676 {
6677 spins = charging = attackclk = 0;
6678 attack=none;
6679 tapping = false;
6680 }
6681
6682 2 sfx(getHurtSFX(),pan(x.getInt()));
6683 2 return;
6684 }
6685
6686 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6687
6688 6504414 hit2 = EwpnHit();
6689
6690
2/2
✓ Branch 0 taken 3115 times.
✓ Branch 1 taken 6501299 times.
6504414 if(hit2!=-1)
6691 {
6692 3115 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6693 3115 std::vector<int32_t> &ev = FFCore.eventData;
6694 3115 ev.clear();
6695 3115 ev.push_back((ewpn_dp(hit2)*10000));
6696 3115 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6697 3115 ev.push_back(0);
6698 3115 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6699 3115 ev.push_back(48*10000);
6700 3115 ev.push_back(ZSD_EWPN*10000);
6701 3115 ev.push_back(ewpnspr->getUID());
6702 3115 ev.push_back(ZSD_NONE*10000);
6703 3115 ev.push_back(0);
6704
6705 3115 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6706 3115 int32_t dmg = ev[0]/10000;
6707 3115 bool nullhit = ev[2] != 0;
6708
6709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3115 times.
3115 if(nullhit) {ev.clear(); return;}
6710
6711 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6712 3115 ev[0] = ringpower(dmg)*10000;
6713
6714 3115 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6715 3115 dmg = ev[0]/10000;
6716 3115 int32_t hdir = ev[1]/10000;
6717 3115 nullhit = ev[2] != 0;
6718 3115 bool divineprot = ev[3] != 0;
6719 3115 int32_t iframes = ev[4] / 10000;
6720 3115 ev.clear();
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3115 times.
3115 if(nullhit) return;
6722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3115 times.
3115 if(!divineprot)
6723 {
6724
2/2
✓ Branch 0 taken 3094 times.
✓ Branch 1 taken 21 times.
3115 game->set_life(zc_max(game->get_life()-dmg,0));
6725 3115 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6726
1/2
✓ Branch 0 taken 3115 times.
✗ Branch 1 not taken.
3115 if (get_qr(qr_BROKENHITBY))
6727 {
6728 3115 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6729 3115 }
6730 else
6731 {
6732
6733 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getScriptUID());
6734 }
6735 3115 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID,ewpnspr->getUID());
6736 3115 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
6737 3115 }
6738
6739 3115 hitdir = hdir;
6740 3115 ewpnspr->onhit(false);
6741
6742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3115 times.
3115 if (IsSideSwim())
6743 {
6744 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6745 }
6746
3/4
✓ Branch 0 taken 3086 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3086 times.
3115 else if(action==swimming || hopclk==0xFF)
6747 {
6748 29 action=swimhit; FFCore.setHeroAction(swimhit);
6749 29 }
6750 else
6751 {
6752 3086 action=gothit; FFCore.setHeroAction(gothit);
6753 }
6754
6755 3115 hclk=iframes;
6756
6757
7/8
✓ Branch 0 taken 3112 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1163 times.
✓ Branch 5 taken 1949 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 1110 times.
3115 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6758 {
6759 2005 spins = charging = attackclk = 0;
6760 2005 attack=none;
6761 2005 tapping = false;
6762 2005 }
6763
6764 3115 sfx(getHurtSFX(),pan(x.getInt()));
6765 3115 return;
6766 }
6767
6768 // The rest of this method deals with damage combos, which can be jumped over.
6769
4/4
✓ Branch 0 taken 6497391 times.
✓ Branch 1 taken 3908 times.
✓ Branch 2 taken 6497391 times.
✓ Branch 3 taken 3908 times.
6501299 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6770
6771 6497391 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6772 6497391 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6773
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 6262098 times.
6497391 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6774
2/2
✓ Branch 0 taken 235293 times.
✓ Branch 1 taken 6262098 times.
6497391 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6775
6776
2/2
✓ Branch 0 taken 6497391 times.
✓ Branch 1 taken 10806357 times.
17303748 for(int32_t i=get_qr(qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6777 10806357 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6778 7262873 }
6779
6780 4507 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6781 {
6782 4507 return checkdamagecombos(dx,dx,dy,dy);
6783 }
6784
6785 183 void HeroClass::doHit(int32_t hdir)
6786 {
6787 183 hitdir = hdir;
6788
6789
3/6
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 183 times.
183 if (action != rafting && action != freeze && action != sideswimfreeze)
6790 {
6791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 if (IsSideSwim())
6792 {
6793 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6794 }
6795
2/4
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 183 times.
183 else if (action == swimming || hopclk == 0xFF)
6796 {
6797 action=swimhit; FFCore.setHeroAction(swimhit);
6798 }
6799 else
6800 {
6801 183 action=gothit; FFCore.setHeroAction(gothit);
6802 }
6803 183 }
6804
6805 183 hclk=48;
6806
6807
5/8
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 183 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 124 times.
183 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6808 {
6809 59 spins = charging = attackclk = 0;
6810 59 attack=none;
6811 59 tapping = false;
6812 59 }
6813
6814 183 sfx(getHurtSFX(),pan(x.getInt()));
6815 183 }
6816
6817 11197732 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6818 {
6819
5/6
✓ Branch 0 taken 11197719 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 11195528 times.
✓ Branch 3 taken 2191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11195528 times.
11197732 if(hclk || superman || fallclk)
6820 2204 return false;
6821
6822 11195528 int32_t hp_mod[4] = {0};
6823 int32_t cid[8];
6824 11195528 byte hasKB = 0;
6825
6826 {
6827
2/2
✓ Branch 0 taken 4565337 times.
✓ Branch 1 taken 6630191 times.
11195528 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6828 11195528 newcombo& cmb = combobuf[cid[0]];
6829
4/4
✓ Branch 0 taken 11195525 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 11194413 times.
✓ Branch 3 taken 1112 times.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6830 {
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 if(cmb.usrflags&cflag1)
6832 hp_mod[0] = cmb.attributes[0] / -10000L;
6833 else
6834 1112 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1112 times.
1112 if(!(cmb.usrflags&cflag2))
6836 1112 hasKB |= 1<<0;
6837 1112 }
6838 }
6839 {
6840
2/2
✓ Branch 0 taken 4565337 times.
✓ Branch 1 taken 6630191 times.
11195528 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6841 11195528 newcombo& cmb = combobuf[cid[1]];
6842
4/4
✓ Branch 0 taken 11195525 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 11194390 times.
✓ Branch 3 taken 1135 times.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6843 {
6844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(cmb.usrflags&cflag1)
6845 hp_mod[1] = cmb.attributes[0] / -10000L;
6846 else
6847 1135 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1135 times.
1135 if(!(cmb.usrflags&cflag2))
6849 1135 hasKB |= 1<<1;
6850 1135 }
6851 }
6852 {
6853
2/2
✓ Branch 0 taken 4565337 times.
✓ Branch 1 taken 6630191 times.
11195528 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6854 11195528 newcombo& cmb = combobuf[cid[2]];
6855
4/4
✓ Branch 0 taken 11195525 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 11194428 times.
✓ Branch 3 taken 1097 times.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6856 {
6857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
1097 if(cmb.usrflags&cflag1)
6858 hp_mod[2] = cmb.attributes[0] / -10000L;
6859 else
6860 1097 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
1097 if(!(cmb.usrflags&cflag2))
6862 1097 hasKB |= 1<<2;
6863 1097 }
6864 }
6865 {
6866
2/2
✓ Branch 0 taken 4565337 times.
✓ Branch 1 taken 6630191 times.
11195528 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
6867 11195528 newcombo& cmb = combobuf[cid[3]];
6868
4/4
✓ Branch 0 taken 11195525 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 11194406 times.
✓ Branch 3 taken 1119 times.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6869 {
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(cmb.usrflags&cflag1)
6871 hp_mod[3] = cmb.attributes[0] / -10000L;
6872 else
6873 1119 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(!(cmb.usrflags&cflag2))
6875 1119 hasKB |= 1<<3;
6876 1119 }
6877 }
6878
6879 11195528 int32_t bestcid=0;
6880 11195528 int best_cpos = -1;
6881 11195528 int32_t hp_modtotal=0;
6882 11195528 int poses[8] = {COMBOPOS(dx1,dy1),COMBOPOS(dx1,dy2),COMBOPOS(dx2,dy1),COMBOPOS(dx2,dy2)};
6883
2/2
✓ Branch 0 taken 8291925 times.
✓ Branch 1 taken 2903603 times.
11195528 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6884
2/2
✓ Branch 0 taken 8285870 times.
✓ Branch 1 taken 2909658 times.
11195528 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6885
2/2
✓ Branch 0 taken 8291957 times.
✓ Branch 1 taken 2903571 times.
11195528 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6886
2/2
✓ Branch 0 taken 8285903 times.
✓ Branch 1 taken 2909625 times.
11195528 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6887
6888
2/2
✓ Branch 0 taken 22391056 times.
✓ Branch 1 taken 11195528 times.
33586584 for (int32_t i = 0; i <= 1; ++i)
6889 {
6890
2/2
✓ Branch 0 taken 16315904 times.
✓ Branch 1 taken 6075152 times.
22391056 if(tmpscr2[i].valid!=0)
6891 {
6892
2/2
✓ Branch 0 taken 5721540 times.
✓ Branch 1 taken 353612 times.
6075152 if (get_qr(qr_OLD_BRIDGE_COMBOS))
6893 {
6894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6898 5721540 }
6899 else
6900 {
6901
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
6902
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
6903
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
6904
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
6905 }
6906 6075152 }
6907 22391056 }
6908
6909
2/2
✓ Branch 0 taken 44782112 times.
✓ Branch 1 taken 11195528 times.
55977640 for(int32_t i=0; i<4; i++)
6910 {
6911
2/2
✓ Branch 0 taken 15509596 times.
✓ Branch 1 taken 29272516 times.
44782112 if(get_qr(qr_DMGCOMBOPRI))
6912 {
6913
2/2
✓ Branch 0 taken 15509436 times.
✓ Branch 1 taken 160 times.
15509596 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
6914 {
6915
2/2
✓ Branch 0 taken 15509373 times.
✓ Branch 1 taken 63 times.
15509436 if(hp_mod[i] < hp_modtotal)
6916 {
6917 63 hp_modtotal = hp_mod[i];
6918 63 bestcid = cid[i];
6919 63 best_cpos = poses[i];
6920 63 }
6921 15509436 }
6922
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 21 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
6923 {
6924
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
6925 {
6926 hp_modtotal = hp_mod[i];
6927 bestcid = cid[i];
6928 best_cpos = poses[i];
6929 }
6930 139 }
6931 15509596 }
6932
2/2
✓ Branch 0 taken 29271388 times.
✓ Branch 1 taken 1128 times.
29272516 else if(hp_mod[i] < hp_modtotal)
6933 {
6934 1128 hp_modtotal = hp_mod[i];
6935 1128 bestcid = cid[i];
6936 1128 best_cpos = poses[i];
6937 1128 }
6938 44782112 }
6939
6940 {
6941 11195528 poses[4] = getFFCAt(dx1,dy1);
6942
2/2
✓ Branch 0 taken 94657 times.
✓ Branch 1 taken 11100871 times.
11195528 cid[4] = poses[4] > -1 ? tmpscr->ffcs[poses[4]].getData() : 0;
6943 11195528 newcombo& cmb = combobuf[cid[4]];
6944
3/4
✓ Branch 0 taken 11195333 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 11195333 times.
✗ Branch 3 not taken.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6945 {
6946 if(cmb.usrflags&cflag1 )
6947 hp_mod[0] = cmb.attributes[0]/10000L;
6948 else
6949 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6950 if(!(cmb.usrflags&cflag2))
6951 hasKB |= 1<<4;
6952 }
6953 }
6954 {
6955 11195528 poses[5] = getFFCAt(dx1,dy2);
6956
2/2
✓ Branch 0 taken 94743 times.
✓ Branch 1 taken 11100785 times.
11195528 cid[5] = poses[5] > -1 ? tmpscr->ffcs[poses[5]].getData() : 0;
6957 11195528 newcombo& cmb = combobuf[cid[5]];
6958
3/4
✓ Branch 0 taken 11195324 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 11195324 times.
✗ Branch 3 not taken.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6959 {
6960 if(cmb.usrflags&cflag1 )
6961 hp_mod[1] = cmb.attributes[0]/10000L;
6962 else
6963 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6964 if(!(cmb.usrflags&cflag2))
6965 hasKB |= 1<<5;
6966 }
6967 }
6968 {
6969 11195528 poses[6] = getFFCAt(dx2,dy1);
6970
2/2
✓ Branch 0 taken 93548 times.
✓ Branch 1 taken 11101980 times.
11195528 cid[6] = poses[6] > -1 ? tmpscr->ffcs[poses[6]].getData() : 0;
6971 11195528 newcombo& cmb = combobuf[cid[6]];
6972
3/4
✓ Branch 0 taken 11195336 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 11195336 times.
✗ Branch 3 not taken.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6973 {
6974 if(cmb.usrflags&cflag1 )
6975 hp_mod[2] = cmb.attributes[0]/10000L;
6976 else
6977 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6978 if(!(cmb.usrflags&cflag2))
6979 hasKB |= 1<<6;
6980 }
6981 }
6982 {
6983 11195528 poses[7] = getFFCAt(dx2,dy2);
6984
2/2
✓ Branch 0 taken 93314 times.
✓ Branch 1 taken 11102214 times.
11195528 cid[7] = poses[7] > -1 ? tmpscr->ffcs[poses[7]].getData() : 0;
6985 11195528 newcombo& cmb = combobuf[cid[7]];
6986
3/4
✓ Branch 0 taken 11195327 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 11195327 times.
✗ Branch 3 not taken.
11195528 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6987 {
6988 if(cmb.usrflags&cflag1 )
6989 hp_mod[3] = cmb.attributes[0]/10000L;
6990 else
6991 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
6992 if(!(cmb.usrflags&cflag2))
6993 hasKB |= 1<<7;
6994 }
6995 }
6996
6997 11195528 int32_t bestffccid = 0;
6998 11195528 int best_ffcpos = -1;
6999 11195528 int32_t hp_modtotalffc = 0;
7000
7001
2/2
✓ Branch 0 taken 22391056 times.
✓ Branch 1 taken 11195528 times.
33586584 for (int32_t i = 0; i <= 1; ++i)
7002 {
7003
2/2
✓ Branch 0 taken 16315904 times.
✓ Branch 1 taken 6075152 times.
22391056 if(tmpscr2[i].valid!=0)
7004 {
7005
2/2
✓ Branch 0 taken 5721540 times.
✓ Branch 1 taken 353612 times.
6075152 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7006 {
7007
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5721540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5721540 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7011 5721540 }
7012 else
7013 {
7014
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7015
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7016
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7017
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 353261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
353612 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7018 }
7019 6075152 }
7020 22391056 }
7021
7022
2/2
✓ Branch 0 taken 44782112 times.
✓ Branch 1 taken 11195528 times.
55977640 for(int32_t i=0; i<4; i++)
7023 {
7024
2/2
✓ Branch 0 taken 376262 times.
✓ Branch 1 taken 44405850 times.
44782112 if(poses[i+4] < 0) continue;
7025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376262 times.
376262 if(get_qr(qr_DMGCOMBOPRI))
7026 {
7027 if(hp_modtotalffc >= 0)
7028 {
7029 if(hp_mod[i] < hp_modtotalffc)
7030 {
7031 hp_modtotalffc = hp_mod[i];
7032 bestffccid = cid[4+i];
7033 best_ffcpos = poses[4+i];
7034 }
7035 }
7036 else if(hp_mod[i] < 0)
7037 {
7038 if(hp_mod[i] > hp_modtotalffc)
7039 {
7040 hp_modtotalffc = hp_mod[i];
7041 bestffccid = cid[4+i];
7042 best_ffcpos = poses[4+i];
7043 }
7044 }
7045 }
7046
2/2
✓ Branch 0 taken 376241 times.
✓ Branch 1 taken 21 times.
376262 else if(hp_mod[i] < hp_modtotalffc)
7047 {
7048 21 hp_modtotalffc = hp_mod[i];
7049 21 bestffccid = cid[4+i];
7050 21 best_ffcpos = poses[4+i];
7051 21 }
7052 376262 }
7053
7054
2/2
✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 11194358 times.
11195528 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7055 11195528 int best_type = 0;
7056
1/2
✓ Branch 0 taken 11195528 times.
✗ Branch 1 not taken.
11195528 if(hp_modtotalffc < hp_modtotal)
7057 {
7058 bestcid = bestffccid;
7059 best_type = 1;
7060 }
7061
7062 11195528 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7063 11195528 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7064 11195528 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7065
1/2
✓ Branch 0 taken 11195528 times.
✗ Branch 1 not taken.
11195528 if(current_ring)
7066 {
7067 global_defring = !global_defring;
7068 global_perilring = !global_perilring;
7069 }
7070 11195528 int32_t itemid = current_item_id(itype_boots);
7071
7072
2/2
✓ Branch 0 taken 10790638 times.
✓ Branch 1 taken 404890 times.
11195528 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7073
2/2
✓ Branch 0 taken 10790638 times.
✓ Branch 1 taken 404890 times.
11195528 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7074
7075
2/2
✓ Branch 0 taken 11194347 times.
✓ Branch 1 taken 1181 times.
11195528 if(hp_modmin<0)
7076 {
7077
10/14
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 997 times.
✓ Branch 10 taken 1002 times.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1002 times.
1181 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7078 {
7079
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 6 times.
189 if (!do_health_check) return true;
7080 183 std::vector<int32_t> &ev = FFCore.eventData;
7081 183 ev.clear();
7082 183 ev.push_back(-hp_modmin*10000);
7083
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 ev.push_back((hasKB ? dir^1 : -1)*10000);
7084 183 ev.push_back(0);
7085 183 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7086 183 ev.push_back(48*10000);
7087 183 ev.push_back(ZSD_COMBODATA*10000);
7088 183 ev.push_back(bestcid);
7089 183 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 ev.push_back(best_type ? best_ffcpos : best_cpos*10000);
7091
7092 183 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7093 183 int32_t dmg = ev[0]/10000;
7094 183 bool nullhit = ev[2] != 0;
7095
7096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 if(nullhit) {ev.clear(); return false;}
7097
7098 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7099 183 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7100
7101 183 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7102 183 dmg = ev[0]/10000;
7103 183 int32_t hdir = ev[1]/10000;
7104 183 nullhit = ev[2] != 0;
7105 183 bool divineprot = ev[3] != 0;
7106 183 int32_t iframes = ev[4] / 10000;
7107 183 ev.clear();
7108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 if(nullhit) return false;
7109
7110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183 times.
183 if(!divineprot)
7111 {
7112
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 6 times.
183 game->set_life(zc_max(game->get_life()-dmg,0));
7113 183 }
7114
7115 183 hitdir = hdir;
7116 183 doHit(hitdir);
7117 183 hclk = iframes;
7118 183 return true;
7119 }
7120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7121 1002 }
7122
7123 11195349 return false;
7124 11197742 }
7125
7126 17407 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7127 {
7128
1/2
✓ Branch 0 taken 17407 times.
✗ Branch 1 not taken.
17407 if(force_hdir > 3) force_hdir = -1;
7129 17407 enemy* enemyptr = (enemy*)guys.spr(hit2);
7130
1/2
✓ Branch 0 taken 17407 times.
✗ Branch 1 not taken.
17407 if(!enemyptr) return 0;
7131 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7132 17407 int32_t stompid = current_item_id(itype_stompboots);
7133
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 17392 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
17407 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7134
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7136 {
7137 paymagiccost(stompid);
7138 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7139
7140 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7141 {
7142 fall = -(itemsbuf[stompid].misc1);
7143 }
7144
7145 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7146 game->set_item(stompid,false);
7147
7148 // Stomp Boots script
7149 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
7150 {
7151 int i = stompid;
7152 FFCore.reset_script_engine_data(ScriptType::Item, i);
7153 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7154 FFCore.deallocateAllArrays(ScriptType::Item, i);
7155 }
7156
7157 return -1;
7158 }
7159
5/6
✓ Branch 0 taken 13363 times.
✓ Branch 1 taken 4044 times.
✓ Branch 2 taken 12990 times.
✓ Branch 3 taken 373 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12990 times.
17407 else if(superman || !(scriptcoldet&1) || fallclk)
7160 4417 return 0;
7161 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7162 //!Add a flag check to this if:
7163
5/6
✓ Branch 0 taken 4475 times.
✓ Branch 1 taken 8515 times.
✓ Branch 2 taken 4475 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2001 times.
✓ Branch 5 taken 2474 times.
12992 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7164
4/4
✓ Branch 0 taken 1756 times.
✓ Branch 1 taken 245 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4228 times.
4475 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7165 {
7166 8760 return -1;
7167 }
7168
7169 4230 std::vector<int32_t> &ev = FFCore.eventData;
7170 4230 ev.clear();
7171 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7172 4230 ev.push_back((enemy_dp(hit2) *10000));
7173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4230 times.
4230 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7174 4230 ev.push_back(0);
7175 4230 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7176 4230 ev.push_back(48*10000);
7177 4230 ev.push_back(ZSD_NPC*10000);
7178 4230 ev.push_back(enemyptr->getUID());
7179 4230 ev.push_back(ZSD_NONE*10000);
7180 4230 ev.push_back(0);
7181
7182 4230 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7183 4230 int32_t dmg = ev[0] / 10000;
7184 4230 bool nullhit = ev[2] != 0;
7185
7186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4230 times.
4230 if(nullhit) {ev.clear(); return -1;}
7187
7188 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7189 4230 ev[0] = ((ringpower(dmg)*10000));
7190
7191 4230 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7192 4230 dmg = ev[0] / 10000;
7193 4230 int32_t hdir = ev[1] / 10000;
7194 4230 nullhit = ev[2] != 0;
7195 4230 bool divineprot = ev[3] != 0;
7196 4230 int32_t iframes = ev[4] / 10000;
7197 4230 ev.clear();
7198
7199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4230 times.
4230 if(nullhit) return -1;
7200
7201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4230 times.
4230 if(!divineprot)
7202 {
7203
2/2
✓ Branch 0 taken 4206 times.
✓ Branch 1 taken 24 times.
4230 game->set_life(zc_max(game->get_life()-dmg,0));
7204 4230 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7205 4230 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7206
1/2
✓ Branch 0 taken 4230 times.
✗ Branch 1 not taken.
4230 if (get_qr(qr_BROKENHITBY))
7207 {
7208 4230 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7209 4230 }
7210 else
7211 {
7212 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->script_UID);
7213 }
7214 4230 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7215 4230 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7216 4230 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->family);
7217 4230 }
7218
7219 4230 hitdir = hdir;
7220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4230 times.
4230 if (IsSideSwim())
7221 {
7222 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7223 }
7224
3/4
✓ Branch 0 taken 4198 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4198 times.
4230 else if(action==swimming || hopclk==0xFF)
7225 {
7226 32 action=swimhit; FFCore.setHeroAction(swimhit);
7227 32 }
7228 else
7229 {
7230 4198 action=gothit; FFCore.setHeroAction(gothit);
7231 }
7232
7233 4230 hclk=iframes;
7234 4230 sfx(getHurtSFX(),pan(x.getInt()));
7235
7236
7/8
✓ Branch 0 taken 4228 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4228 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1859 times.
✓ Branch 5 taken 2369 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1811 times.
4230 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7237 {
7238 2419 spins = charging = attackclk = 0;
7239 2419 attack=none;
7240 2419 tapping = false;
7241 2419 }
7242
7243 4230 enemy_scored(hit2);
7244 4230 int32_t dm7 = enemyptr->dmisc7;
7245 4230 int32_t dm8 = enemyptr->dmisc8;
7246
7247
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2254 times.
4230 switch(enemyptr->family)
7248 {
7249 case eeWALLM:
7250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7251 {
7252 3 GrabHero(hit2);
7253 3 inwallm=true;
7254 3 action=none; FFCore.setHeroAction(none);
7255 3 }
7256 3 break;
7257
7258 //case eBUBBLEST:
7259 //case eeBUBBLE:
7260 case eeWALK:
7261 {
7262 2254 int32_t itemid = current_item_id(itype_whispring);
7263 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7264
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2254 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7265
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
2254 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7266
7267
5/7
✓ Branch 0 taken 1803 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 85 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
2254 switch(dm7)
7268 {
7269 case e7tTEMPJINX:
7270
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 263 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
282 if(dm8==0 || dm8==2)
7271
4/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 259 times.
522 if(swordclk>=0 && !(sworddivisor==0))
7272 259 swordclk=150;
7273
7274
3/4
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
282 if(dm8==1 || dm8==2)
7275
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7276 18 itemclk=150;
7277
7278 282 break;
7279
7280 case e7tPERMJINX:
7281
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
63 if(dm8==0 || dm8==2)
7282
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
41 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7283
7284
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
63 if(dm8==1 || dm8==2)
7285
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
22 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7286
7287 63 break;
7288
7289 case e7tUNJINX:
7290
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
85 if(dm8==0 || dm8==2)
7291 70 swordclk=0;
7292
7293
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
85 if(dm8==1 || dm8==2)
7294 15 itemclk=0;
7295
7296 85 break;
7297
7298 case e7tTAKEMAGIC:
7299 game->change_dmagic(-dm8*game->get_magicdrainrate());
7300 break;
7301
7302 case e7tTAKERUPEES:
7303 21 game->change_drupy(-dm8);
7304 21 break;
7305
7306 case e7tDRUNK:
7307 drunkclk += dm8;
7308 break;
7309 }
7310 2254 verifyAWpn();
7311
2/2
✓ Branch 0 taken 2203 times.
✓ Branch 1 taken 51 times.
2254 if(dm7 >= e7tEATITEMS)
7312 {
7313 51 EatHero(hit2);
7314 51 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7315 51 action=none; FFCore.setHeroAction(none);
7316 51 }
7317 }
7318 2254 }
7319 4230 return 0;
7320 17407 }
7321
7322 344510 void HeroClass::addsparkle(int32_t wpn)
7323 {
7324 //return;
7325 344510 weapon *w = (weapon*)Lwpns.spr(wpn);
7326 344510 int32_t itemid = w->parentitem;
7327
7328
2/2
✓ Branch 0 taken 339009 times.
✓ Branch 1 taken 5501 times.
344510 if(itemid<0)
7329 5501 return;
7330
7331 339009 int32_t itemtype = itemsbuf[itemid].family;
7332
7333
4/4
✓ Branch 0 taken 338936 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 84726 times.
✓ Branch 3 taken 254210 times.
339009 if(itemtype!=itype_cbyrna && frame%4)
7334 254210 return;
7335
7336
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 84726 times.
84799 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7337
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 84726 times.
84799 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7338 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7339
5/8
✓ Branch 0 taken 24517 times.
✓ Branch 1 taken 60282 times.
✓ Branch 2 taken 43573 times.
✓ Branch 3 taken 16709 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24517 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
84799 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7340 84799 int32_t direction=w->dir;
7341
7342
2/2
✓ Branch 0 taken 43573 times.
✓ Branch 1 taken 41226 times.
84799 if(sparkle_type)
7343 {
7344 41226 int32_t h=0;
7345 41226 int32_t v=0;
7346
7347
6/6
✓ Branch 0 taken 32970 times.
✓ Branch 1 taken 8256 times.
✓ Branch 2 taken 29321 times.
✓ Branch 3 taken 3649 times.
✓ Branch 4 taken 6364 times.
✓ Branch 5 taken 22957 times.
41226 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7348 {
7349 18269 h=-1;
7350 18269 }
7351
7352
6/6
✓ Branch 0 taken 33210 times.
✓ Branch 1 taken 8016 times.
✓ Branch 2 taken 27643 times.
✓ Branch 3 taken 5567 times.
✓ Branch 4 taken 4076 times.
✓ Branch 5 taken 23567 times.
41226 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7353 {
7354 17659 h=1;
7355 17659 }
7356
7357
6/6
✓ Branch 0 taken 38909 times.
✓ Branch 1 taken 2317 times.
✓ Branch 2 taken 34833 times.
✓ Branch 3 taken 4076 times.
✓ Branch 4 taken 6364 times.
✓ Branch 5 taken 28469 times.
41226 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7358 {
7359 12757 v=-1;
7360 12757 }
7361
7362
6/6
✓ Branch 0 taken 38245 times.
✓ Branch 1 taken 2981 times.
✓ Branch 2 taken 32678 times.
✓ Branch 3 taken 5567 times.
✓ Branch 4 taken 3649 times.
✓ Branch 5 taken 29029 times.
41226 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7363 {
7364 12197 v=1;
7365 12197 }
7366
7367 // Damaging boomerang sparkle?
7368
3/4
✓ Branch 0 taken 16709 times.
✓ Branch 1 taken 24517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16709 times.
41226 if(wpn3 && itemtype==itype_brang)
7369 {
7370 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7371 // whatever it just bounced off of if it's shielded from that direction.
7372
6/6
✓ Branch 0 taken 10964 times.
✓ Branch 1 taken 5745 times.
✓ Branch 2 taken 10517 times.
✓ Branch 3 taken 447 times.
✓ Branch 4 taken 4476 times.
✓ Branch 5 taken 6041 times.
16709 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7373 6041 direction=oppositeDir[direction];
7374 16709 }
7375
4/4
✓ Branch 0 taken 40281 times.
✓ Branch 1 taken 945 times.
✓ Branch 2 taken 20671 times.
✓ Branch 3 taken 19610 times.
41226 if(itemtype==itype_brang && get_qr(qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7376
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 41153 times.
41226 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7377
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 41153 times.
41226 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7378
5/10
✓ Branch 0 taken 41226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41226 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41226 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 41226 times.
✗ Branch 9 not taken.
41226 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7379 41226 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7380 41226 }
7381 344510 }
7382
7383 // For wPhantoms
7384 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7385 {
7386 if(frame%4) return;
7387
7388 int32_t arrow = -1;
7389
7390 for(int32_t i=0; i<Lwpns.Count(); i++)
7391 {
7392 weapon *w = (weapon*)Lwpns.spr(i);
7393
7394 if(w->id == wPhantom && w->type == type1)
7395 {
7396 arrow = i;
7397 break;
7398 }
7399 }
7400
7401 if(arrow==-1)
7402 {
7403 return;
7404 }
7405
7406 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7407 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7408 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7409 }
7410
7411 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7412 7262477 void HeroClass::PhantomsCleanup()
7413 {
7414
1/2
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
7262477 if(Lwpns.idCount(wPhantom))
7415 {
7416 for(int32_t i=0; i<Lwpns.Count(); i++)
7417 {
7418 weapon *w = ((weapon *)Lwpns.spr(i));
7419 if ( w->id == wPhantom && !w->isScriptGenerated() )
7420 {
7421 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7422 {
7423 Lwpns.remove(w);
7424 }
7425 }
7426 }
7427 }
7428 7262477 }
7429
7430 //Waitframe handler for refilling operations
7431 4932 static void do_refill_waitframe()
7432 {
7433 4932 put_passive_subscr(framebuf,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7434
1/2
✓ Branch 0 taken 4932 times.
✗ Branch 1 not taken.
4932 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7435 {
7436 script_drawing_commands.Clear();
7437 if(DMaps[currdmap].passive_sub_script != 0)
7438 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7439
7440 if (FFCore.waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
7441 {
7442 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
7443 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
7444 }
7445 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7446 }
7447 4932 advanceframe(true);
7448 4932 }
7449 //Special handler if it's a "fairy revive"
7450 static void do_death_refill_waitframe()
7451 {
7452 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7453 //This script should be able to draw a 'fairy saving the player' animation -Em
7454 do_refill_waitframe();
7455 }
7456
7457 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7458 {
7459 int32_t found_unowned = -1;
7460 for(int q = 0; q < MAXITEMS; ++q)
7461 {
7462 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7463 {
7464 if(game->get_item(q))
7465 return q;
7466 if(unowned)
7467 found_unowned = q;
7468 }
7469 }
7470 return found_unowned;
7471 }
7472
7473 int32_t getPushDir(int32_t flag)
7474 {
7475 switch(flag)
7476 {
7477 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7478 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7479 case mfPUSHUINS:
7480 return up;
7481 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7482 return down;
7483 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7484 case mfPUSHLRINS: case mfPUSHLINS:
7485 return left;
7486 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7487 return right;
7488 }
7489 return -1;
7490 }
7491
7492 void post_item_collect();
7493
7494 7262874 bool HeroClass::handle_portal_collide(portal* p)
7495 {
7496
1/2
✓ Branch 0 taken 7262874 times.
✗ Branch 1 not taken.
7262874 if(!p) return false;
7497 7262874 p->animate(0);
7498
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262874 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262874 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7499 7262874 return false;
7500 if(abs(x - p->x) < 12
7501 && abs(y - p->y) < 12)
7502 {
7503 if(p->prox_active)
7504 {
7505 //Store some values to restore if 'warp fails'
7506 int32_t tLastEntrance = lastentrance,
7507 tLastEntranceDMap = lastentrance_dmap,
7508 tContScr = game->get_continue_scrn(),
7509 tContDMap = game->get_continue_dmap();
7510 int32_t sourcescr = currscr, sourcedmap = currdmap;
7511 zfix tx = x, ty = y, tz = z;
7512 x = p->x;
7513 y = p->y;
7514
7515 int32_t weff = p->weffect,
7516 wsfx = p->wsfx;
7517
7518 int32_t savep = p->saved_data;
7519 //After this line, 'p' becomes INVALID!
7520 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7521 -1, -1, weff, wsfx, 0, -1);
7522
7523 if(mirrorBonk()) //Invalid landing, warp back!
7524 {
7525 action = none; FFCore.setHeroAction(none);
7526 lastentrance = tLastEntrance;
7527 lastentrance_dmap = tLastEntranceDMap;
7528 game->set_continue_scrn(tContScr);
7529 game->set_continue_dmap(tContDMap);
7530 x = tx;
7531 y = ty;
7532 z = tz;
7533 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7534 wsfx, 0, -1);
7535 handle_portal_prox(&mirror_portal);
7536 portals.forEach([&](sprite& p)
7537 {
7538 handle_portal_prox((portal*)&p);
7539 return false;
7540 });
7541 }
7542 else game->clear_portal(savep); //Remove portal once used
7543 return true;
7544 }
7545 }
7546 else p->prox_active = true;
7547 return false;
7548 7262874 }
7549 17 void HeroClass::handle_portal_prox(portal* p)
7550 {
7551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!p) return;
7552
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
17 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7553 17 }
7554 // returns true when game over
7555 21260775 bool HeroClass::animate(int32_t)
7556 {
7557 21260775 int32_t lsave=0;
7558
1/2
✓ Branch 0 taken 21260775 times.
✗ Branch 1 not taken.
21260775 if(immortal > 0)
7559 --immortal;
7560 21260775 prompt_combo = 0;
7561
2/2
✓ Branch 0 taken 13997901 times.
✓ Branch 1 taken 7262874 times.
21260775 if (onpassivedmg)
7562 {
7563 13997901 onpassivedmg=false;
7564 13997901 }
7565
1/2
✓ Branch 0 taken 7262874 times.
✗ Branch 1 not taken.
7262874 else if (damageovertimeclk)
7566 {
7567 damageovertimeclk = 0;
7568 }
7569
7570
2/2
✓ Branch 0 taken 21259682 times.
✓ Branch 1 taken 1093 times.
21260775 if(lift_wpn)
7571 {
7572 1093 auto oldid = lift_wpn->id;
7573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1093 times.
1093 switch(lift_wpn->id)
7574 {
7575 case wLitBomb:
7576 case wBomb:
7577 case wLitSBomb:
7578 case wSBomb:
7579 if(lift_wpn->misc && get_qr(qr_HELD_BOMBS_EXPLODE)) //timed fuse
7580 {
7581 lift_wpn->limited_animate();
7582 if(lift_wpn->id != oldid)
7583 {
7584 lift_wpn->moveflags &= ~FLAG_OBEYS_GRAV;
7585 drop_liftwpn();
7586 goto heroanimate_skip_liftwpn;
7587 }
7588 ++lift_wpn->clk;
7589 }
7590 break;
7591 }
7592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1093 times.
1093 if(lift_wpn->dead>0)
7593 --lift_wpn->dead;
7594
7595
1/2
✓ Branch 0 taken 1093 times.
✗ Branch 1 not taken.
1093 if(lift_wpn->dead==0)
7596 {
7597 if(lift_wpn->death_spawnitem > -1)
7598 {
7599 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7600 itm->fakez = lift_wpn->fakez;
7601 items.add(itm);
7602 }
7603 if(lift_wpn->death_spawndropset > -1)
7604 {
7605 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7606 if(itid > -1)
7607 {
7608 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7609 itm->fakez = lift_wpn->fakez;
7610 itm->from_dropset = lift_wpn->death_spawndropset;
7611 items.add(itm);
7612 }
7613 }
7614 switch(lift_wpn->death_sprite)
7615 {
7616 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7617 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7618 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7619 default:
7620 if(lift_wpn->death_sprite < 0) break;
7621 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dCOMBOSPRITE, 0, lift_wpn->death_sprite));
7622 }
7623 if(lift_wpn->death_sfx > 0)
7624 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7625 delete lift_wpn;
7626 lift_wpn = nullptr;
7627 }
7628 heroanimate_skip_liftwpn:;
7629 1093 }
7630
7631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21260775 times.
21260775 if(cheats_execute_goto)
7632 {
7633 didpit=true;
7634 pitx=x;
7635 pity=y;
7636 dowarp(3,0);
7637 cheats_execute_goto=false;
7638 solid_update(false);
7639 return false;
7640 }
7641
7642
1/2
✓ Branch 0 taken 21260775 times.
✗ Branch 1 not taken.
21260775 if(cheats_execute_light)
7643 {
7644 naturaldark = !naturaldark;
7645 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7646 cheats_execute_light = false;
7647 }
7648
7649
3/4
✓ Branch 0 taken 7262874 times.
✓ Branch 1 taken 13997901 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7262874 times.
21260775 if(action!=climbcovertop&&action!=climbcoverbottom)
7650 {
7651 7262874 climb_cover_x=-1000;
7652 7262874 climb_cover_y=-1000;
7653 7262874 }
7654
7655 21260775 handle_portal_collide(&mirror_portal);
7656
1/2
✓ Branch 0 taken 21260775 times.
✗ Branch 1 not taken.
21260775 portals.forEach([&](sprite& p)
7657 {
7658 return handle_portal_collide((portal*)&p);
7659 });
7660
7661
3/4
✓ Branch 0 taken 7259264 times.
✓ Branch 1 taken 14001511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7259264 times.
21260775 if(z<=8&&fakez<=8) //Tall Grass
7662 {
7663
2/2
✓ Branch 0 taken 42652 times.
✓ Branch 1 taken 7216612 times.
7259264 if (get_qr(qr_GRASS_SENSITIVE))
7664 {
7665 42652 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7666
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 1121 times.
42652 if(get_qr(qr_BUSHESONLAYERS1AND2))
7667 {
7668
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7669
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7670
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7671
2/4
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1121 times.
1121 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7672 1121 }
7673
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42652 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42652 if(g1 && g2 && g3 && g4)
7674 {
7675 int grasscid = MAPCOMBO(x+8,y+12);
7676 newcombo const& cmb = combobuf[grasscid];
7677 if(decorations.idCount(dTALLGRASS)==0)
7678 {
7679 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7680 }
7681 int32_t thesfx = cmb.attribytes[3];
7682 if (action==walking)
7683 sfx_no_repeat(thesfx,pan((int32_t)x));
7684 }
7685 42652 }
7686 else
7687 {
7688 7216612 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7689
2/2
✓ Branch 0 taken 7193466 times.
✓ Branch 1 taken 23146 times.
7216612 if(get_qr(qr_BUSHESONLAYERS1AND2))
7690 {
7691
3/4
✓ Branch 0 taken 22597 times.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22597 times.
23146 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7692
3/4
✓ Branch 0 taken 22597 times.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22597 times.
23146 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7693 23146 }
7694
4/4
✓ Branch 0 taken 75441 times.
✓ Branch 1 taken 7141171 times.
✓ Branch 2 taken 13126 times.
✓ Branch 3 taken 62315 times.
7216612 if(g1 && g2)
7695 {
7696 62315 int grasscid = MAPCOMBO(x+8,y+15);
7697 62315 newcombo const& cmb = combobuf[grasscid];
7698
2/2
✓ Branch 0 taken 61039 times.
✓ Branch 1 taken 1276 times.
62315 if(decorations.idCount(dTALLGRASS)==0)
7699 {
7700
3/6
✓ Branch 0 taken 1276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1276 times.
✗ Branch 5 not taken.
1276 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
7701 1276 }
7702 62315 int32_t thesfx = cmb.attribytes[3];
7703
2/2
✓ Branch 0 taken 22150 times.
✓ Branch 1 taken 40165 times.
62315 if (action==walking )
7704 40165 sfx_no_repeat(thesfx,pan((int32_t)x));
7705 62315 }
7706 }
7707 7259264 }
7708
3/4
✓ Branch 0 taken 7258957 times.
✓ Branch 1 taken 14001818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7258957 times.
21260775 if(z==0 && fakez==0) //Shallow Water / Custom Walk SFX
7709 {
7710
2/2
✓ Branch 0 taken 278786 times.
✓ Branch 1 taken 6980171 times.
7258957 if (get_qr(qr_SHALLOW_SENSITIVE))
7711 {
7712
17/22
✓ Branch 0 taken 277507 times.
✓ Branch 1 taken 1279 times.
✓ Branch 2 taken 277507 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276867 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 276867 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 276867 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 276867 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 276377 times.
✓ Branch 13 taken 490 times.
✓ Branch 14 taken 276377 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 276344 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 276284 times.
✓ Branch 19 taken 60 times.
✓ Branch 20 taken 949 times.
✓ Branch 21 taken 275335 times.
278786 if (action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7713 {
7714
2/2
✓ Branch 0 taken 252192 times.
✓ Branch 1 taken 23143 times.
299997 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7715
2/2
✓ Branch 0 taken 24662 times.
✓ Branch 1 taken 250673 times.
275335 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7716
2/2
✓ Branch 0 taken 23795 times.
✓ Branch 1 taken 867 times.
24662 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7717
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 23177 times.
23795 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7718 {
7719 23143 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
7720 23143 int ffpos = getFFCAt(watercheck_x,watercheck_y);
7721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23143 times.
23143 int combopos = ffpos < 0 ? COMBOPOS(watercheck_x,watercheck_y) : -1;
7722
4/8
✓ Branch 0 taken 23143 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23143 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 23143 times.
23143 if(watercheck_x < 0 || watercheck_x > 255 || watercheck_y < 0 || watercheck_y > 175)
7723 combopos = -1;
7724
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23143 times.
✓ Branch 2 taken 23143 times.
✗ Branch 3 not taken.
23143 int waterid = ffpos > -1 ? tmpscr->ffcs[ffpos].getData() : (combopos > -1 ? tmpscr->data[combopos] : 0);
7725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23143 times.
23143 if(waterid)
7726 23143 waterid = iswaterex(waterid, currmap, currscr, -1, watercheck_x,watercheck_y, false, false, true, true);
7727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23143 times.
23143 if(waterid)
7728 {
7729 23143 newcombo const& watercmb = combobuf[waterid];
7730 23143 auto ripplesprite = watercmb.attribytes[6];
7731
2/2
✓ Branch 0 taken 22985 times.
✓ Branch 1 taken 158 times.
23143 if(decorations.idCount(dRIPPLES)==0)
7732
3/6
✓ Branch 0 taken 158 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
158 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
7733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23143 times.
23143 if (watercmb.usrflags&cflag2)
7734 {
7735 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
7736 {
7737 onpassivedmg = true;
7738 if (!damageovertimeclk)
7739 {
7740 int32_t curhp = game->get_life();
7741 auto dmg = watercmb.attributes[1]/10000L;
7742 auto hitsfx = watercmb.attributes[2]/10000L;
7743 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
7744
7745 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
7746 hitsfx = 0;
7747
7748 std::vector<int32_t> &ev = FFCore.eventData;
7749 ev.clear();
7750 ev.push_back(-dmg*10000);
7751 ev.push_back(-1*10000);
7752 ev.push_back(0);
7753 ev.push_back(0);
7754 ev.push_back(48*10000);
7755 ev.push_back(ZSD_COMBODATA*10000);
7756 ev.push_back(waterid);
7757 ev.push_back((ffpos > -1 ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7758 ev.push_back(ffpos > -1 ? ffpos : combopos*10000);
7759
7760 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7761
7762 if(watercmb.usrflags & cflag5)
7763 ev[0] = ringpower(ev[0]/10000) * 10000;
7764
7765 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7766 dmg = -ev[0]/10000;
7767
7768 if(!ev[2]) //nullify
7769 {
7770 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
7771 if (hitsfx)
7772 sfx(hitsfx);
7773 if (hitstun)
7774 {
7775 hclk = ev[4]/10000;
7776 hitdir = ev[1]/10000;
7777 action = gothit; FFCore.setHeroAction(gothit);
7778 }
7779 }
7780 }
7781 if (watercmb.attribytes[1] > 0)
7782 {
7783 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
7784 else --damageovertimeclk;
7785 }
7786 else damageovertimeclk = 0;
7787 }
7788 else damageovertimeclk = 0;
7789 }
7790 23143 else damageovertimeclk = 0;
7791 23143 int32_t thesfx = watercmb.attribytes[0];
7792
3/4
✓ Branch 0 taken 22813 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22813 times.
✗ Branch 3 not taken.
23143 if (watercmb.type != cSHALLOWWATER || !get_qr(qr_OLD_SHALLOW_SFX))
7793 {
7794 330 thesfx = watercmb.attribytes[5];
7795 330 }
7796
2/2
✓ Branch 0 taken 12801 times.
✓ Branch 1 taken 10342 times.
23143 if (action==walking)
7797 10342 sfx_no_repeat(thesfx,pan((int32_t)x));
7798 23143 }
7799 23143 }
7800 275335 }
7801 278786 }
7802 else
7803 {
7804
4/4
✓ Branch 0 taken 6947183 times.
✓ Branch 1 taken 32988 times.
✓ Branch 2 taken 6948508 times.
✓ Branch 3 taken 31663 times.
6980171 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER))
7805 {
7806 31663 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7807 31663 auto ripplesprite = combobuf[watercheck].attribytes[6];
7808
2/2
✓ Branch 0 taken 31479 times.
✓ Branch 1 taken 184 times.
31663 if(decorations.idCount(dRIPPLES)==0)
7809 {
7810
3/6
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 184 times.
✗ Branch 5 not taken.
184 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
7811 184 }
7812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31663 times.
31663 if (combobuf[watercheck].usrflags&cflag2)
7813 {
7814 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7815 {
7816 onpassivedmg = true;
7817 if (!damageovertimeclk)
7818 {
7819 int32_t curhp = game->get_life();
7820 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7821 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7822 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7823 }
7824 if (combobuf[watercheck].attribytes[1] > 0)
7825 {
7826 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7827 else --damageovertimeclk;
7828 }
7829 else damageovertimeclk = 0;
7830 }
7831 else damageovertimeclk = 0;
7832 }
7833 31663 else damageovertimeclk = 0;
7834 31663 int32_t thesfx = combobuf[watercheck].attribytes[0];
7835
2/2
✓ Branch 0 taken 14648 times.
✓ Branch 1 taken 17015 times.
31663 if (action==walking )
7836 17015 sfx_no_repeat(thesfx,pan((int32_t)x));
7837 31663 }
7838 }
7839
7840 7258957 auto cpos = COMBOPOS(x+8,y+(sideview_mode()?16:12));
7841
2/2
✓ Branch 0 taken 50812699 times.
✓ Branch 1 taken 7258957 times.
58071656 for(int q = 0; q < 7; ++q)
7842 {
7843 50812699 mapscr* lyr = FFCore.tempScreens[q];
7844 50812699 auto cid = lyr->data[cpos];
7845 50812699 newcombo const& cmb = combobuf[cid];
7846
2/2
✓ Branch 0 taken 25992246 times.
✓ Branch 1 taken 24820453 times.
50812699 byte csfx = action == walking ? cmb.sfx_walking : cmb.sfx_standing;
7847
2/2
✓ Branch 0 taken 25992246 times.
✓ Branch 1 taken 24820453 times.
50812699 byte cspr = action == walking ? cmb.spr_walking : cmb.spr_standing;
7848
1/2
✓ Branch 0 taken 50812699 times.
✗ Branch 1 not taken.
50812699 if(csfx)
7849 sfx_no_repeat(csfx);
7850 50812699 auto indx = decorations.idFirst(dCUSTOMWALK);
7851
1/2
✓ Branch 0 taken 50812699 times.
✗ Branch 1 not taken.
50812699 if(cspr)
7852 {
7853 if(indx < 0)
7854 {
7855 if(decorations.add(new customWalkSprite(x, y, dCUSTOMWALK, 0, -1)))
7856 indx = decorations.Count()-1;
7857 }
7858 if(indx > -1)
7859 {
7860 if(customWalkSprite* spr = dynamic_cast<customWalkSprite*>(decorations.spr(indx)))
7861 spr->run_sprite(cspr);
7862 }
7863 }
7864 50812699 }
7865 7258957 }
7866
7867
2/2
✓ Branch 0 taken 21260732 times.
✓ Branch 1 taken 43 times.
21260775 if(stomping)
7868 43 stomping = false;
7869
7870
1/2
✓ Branch 0 taken 21260775 times.
✗ Branch 1 not taken.
21260775 if(getOnSideviewLadder())
7871 {
7872 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7873 {
7874 setOnSideviewLadder(false);
7875 }
7876 else if(CANFORCEFACEUP)
7877 {
7878 setDir(up);
7879 }
7880 }
7881
7882
6/8
✓ Branch 0 taken 7253174 times.
✓ Branch 1 taken 14007601 times.
✓ Branch 2 taken 7252534 times.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 7252534 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7252534 times.
21260775 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7883 {
7884
2/2
✓ Branch 0 taken 7097139 times.
✓ Branch 1 taken 155395 times.
7252534 if(!get_qr(qr_OLD_CHEST_COLLISION))
7885 {
7886 155395 checkchest(cCHEST);
7887 155395 checkchest(cLOCKEDCHEST);
7888 155395 checkchest(cBOSSCHEST);
7889 155395 }
7890
2/2
✓ Branch 0 taken 7227755 times.
✓ Branch 1 taken 24779 times.
7252534 if(!get_qr(qr_OLD_LOCKBLOCK_COLLISION))
7891 {
7892 24779 checkchest(cLOCKBLOCK);
7893 24779 checkchest(cBOSSLOCKBLOCK);
7894 24779 }
7895 7252534 }
7896 21260775 checksigns();
7897 21260775 checkgenpush();
7898
7899
4/4
✓ Branch 0 taken 6837054 times.
✓ Branch 1 taken 14423721 times.
✓ Branch 2 taken 2192 times.
✓ Branch 3 taken 6834862 times.
21260775 if(isStanding(true) && fall == 0)
7900 {
7901
1/2
✓ Branch 0 taken 6834862 times.
✗ Branch 1 not taken.
6834862 if(extra_jump_count > 0)
7902 extra_jump_count = 0;
7903 6834862 coyotetime = 0;
7904 6834862 }
7905
2/2
✓ Branch 0 taken 13998960 times.
✓ Branch 1 taken 426953 times.
14425913 else if(coyotetime < 65535)
7906 {
7907 426953 ++coyotetime;
7908 426953 }
7909
2/2
✓ Branch 0 taken 21250684 times.
✓ Branch 1 taken 10091 times.
21260775 if(can_use_item(itype_hoverboots,i_hoverboots))
7910 {
7911 10091 int32_t hoverid = current_item_id(itype_hoverboots);
7912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10091 times.
10091 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7913 {
7914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10091 times.
10091 if(hoverclk < 0) hoverclk = 0;
7915 10091 hoverflags &= ~HOV_OUT;
7916 10091 }
7917 10091 }
7918 21260775 bool platformfell2 = false;
7919 21260775 int32_t gravity3 = (zinit.gravity2/100);
7920 21260775 int32_t termv = (zinit.terminalv);
7921 21260775 int32_t rocs = getRocsPressed();
7922
2/2
✓ Branch 0 taken 21260471 times.
✓ Branch 1 taken 304 times.
21260775 if (rocs != -1)
7923 {
7924 304 itemdata const& itm = itemsbuf[rocs];
7925
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (itm.flags & ITEM_FLAG2)
7926 {
7927 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7928 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7929 }
7930
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (itm.flags & ITEM_FLAG5)
7931 {
7932 termv = itm.misc4;
7933 if (fall > termv) fall = termv;
7934 }
7935 304 }
7936
2/2
✓ Branch 0 taken 252244 times.
✓ Branch 1 taken 21008531 times.
21260775 if(sideview_mode()) // Sideview gravity
7937 {
7938 //Handle falling through a platform
7939 252244 bool platformfell = false;
7940
3/4
✓ Branch 0 taken 127500 times.
✓ Branch 1 taken 124744 times.
✓ Branch 2 taken 127500 times.
✗ Branch 3 not taken.
252244 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7941 {
7942 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7943 y+=1; //Fall down a pixel instantly, through the platform.
7944 if(fall < 0) fall = 0;
7945 if(jumping < 0) jumping = 0;
7946 platformfell2 = true;
7947 }
7948 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7949
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 1548 times.
252244 if(!get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
7950 {
7951
2/22
✓ Branch 0 taken 1548 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1548 times.
✗ Branch 21 not taken.
1548 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7952 || ((y+(fall/100)<=0) &&
7953 // Extra checks if Smart Screen Scrolling is enabled
7954 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7955 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7956 {
7957 fall = jumping = 0; // Bumped his head
7958 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
7959 y -= y.getInt()%8; //fix coords
7960 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7961 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7962 {
7963 checkdamagecombos(x+4, x+12, y-1, y-1);
7964 }
7965 }
7966 1548 }
7967 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7968
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 252244 times.
✓ Branch 2 taken 252244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252244 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 252244 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 252244 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 252244 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 252244 times.
252244 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7969 {
7970
1/2
✓ Branch 0 taken 252244 times.
✗ Branch 1 not taken.
252244 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7971 //zprint2("ydif is: %d\n", ydiff);
7972 //zprint2("ydif is: %d\n", (int32_t)fall);
7973 252244 falling_oldy = y; // Stomp Boots-related variable
7974
5/8
✓ Branch 0 taken 47145 times.
✓ Branch 1 taken 205099 times.
✓ Branch 2 taken 47145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 252244 times.
✗ Branch 7 not taken.
252244 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7975 {
7976 ydiff -= (y.getInt()+ydiff)%16;
7977 }
7978
4/4
✓ Branch 0 taken 66921 times.
✓ Branch 1 taken 185323 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 127 times.
252244 if(ydiff && !get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
7979 {
7980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(ydiff > 0)
7981 {
7982
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 210 times.
332 for(auto q = 0; q < ydiff; ++q)
7983 {
7984
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 5 times.
210 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7985 {
7986 5 ydiff = q;
7987 5 break;
7988 }
7989 205 }
7990 127 }
7991 else if(ydiff < 0)
7992 {
7993 for(auto q = 0; q > ydiff; --q)
7994 {
7995 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7996 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7997 {
7998 ydiff = q;
7999 break;
8000 }
8001 }
8002 }
8003 127 }
8004 252244 y+=ydiff;
8005 252244 hs_starty+=ydiff;
8006
8007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252244 times.
252244 for(int32_t j=0; j<chainlinks.Count(); j++)
8008 {
8009 chainlinks.spr(j)->y+=ydiff;
8010 }
8011
8012
1/2
✓ Branch 0 taken 252244 times.
✗ Branch 1 not taken.
252244 if(Lwpns.idFirst(wHookshot)>-1)
8013 {
8014 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
8015 }
8016
8017
1/2
✓ Branch 0 taken 252244 times.
✗ Branch 1 not taken.
252244 if(Lwpns.idFirst(wHSHandle)>-1)
8018 {
8019 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
8020 }
8021 252244 }
8022 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
8023 {
8024 fall = hoverclk = jumping = 0;
8025 inair = false;
8026 hoverflags = 0;
8027 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
8028 {
8029 WalkflagInfo info;
8030 if (game->get_watergrav()<0)
8031 {
8032 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
8033 execute(info);
8034 }
8035 else
8036 {
8037 info = walkflag(x,y+15+2,2,down);
8038 execute(info);
8039 }
8040 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
8041 }
8042 }
8043 // Stop hovering/falling if you land on something.
8044 252244 bool needFall = false;
8045
6/8
✓ Branch 0 taken 124253 times.
✓ Branch 1 taken 127991 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 252244 times.
✓ Branch 4 taken 127991 times.
✓ Branch 5 taken 124253 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 127991 times.
252244 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
8046 {
8047 127991 stop_item_sfx(itype_hoverboots);
8048
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 1331 times.
127991 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8049 {
8050
4/6
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
✓ Branch 4 taken 124016 times.
✗ Branch 5 not taken.
126660 if(!getOnSideviewLadder() && (fall > 0 || get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8051 {
8052 126660 y.doFloor();
8053 126660 y-=(int32_t)y%8; //fix position
8054 126660 }
8055 126660 }
8056 else
8057 {
8058 1331 snap_platform();
8059 }
8060 127991 fall = hoverclk = jumping = 0;
8061 127991 inair = false;
8062 127991 hoverflags = 0;
8063
8064
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 127983 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
127991 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
8065 8 y = 160;
8066 127991 }
8067 // Stop hovering if you press down.
8068
3/6
✓ Branch 0 taken 124253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124253 times.
✗ Branch 5 not taken.
124253 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8069 {
8070 stop_item_sfx(itype_hoverboots);
8071 hoverclk = -hoverclk;
8072 reset_ladder();
8073 fall = gravity3;
8074 inair = false;
8075 }
8076
9/12
✓ Branch 0 taken 124253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2780 times.
✓ Branch 3 taken 121473 times.
✓ Branch 4 taken 1075 times.
✓ Branch 5 taken 1705 times.
✓ Branch 6 taken 1075 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1075 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 282 times.
✓ Branch 11 taken 793 times.
124253 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
8077 {
8078 793 zfix my = y + 4;
8079 793 needFall = true;
8080
2/2
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 2086 times.
2699 for (zfix ty = y+1; ty < my; ++ty)
8081 {
8082 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
8083
2/2
✓ Branch 0 taken 1906 times.
✓ Branch 1 taken 180 times.
2086 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
8084 {
8085 180 y = ty;
8086
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 48 times.
180 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8087 {
8088
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!slopeid)
8089 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8090 48 onplatid = 5;
8091 48 }
8092 180 needFall = false;
8093 180 break;
8094 }
8095 1906 }
8096 793 }
8097 123460 else needFall = true;
8098 // Continue falling.
8099
8100
4/4
✓ Branch 0 taken 244990 times.
✓ Branch 1 taken 7254 times.
✓ Branch 2 taken 128171 times.
✓ Branch 3 taken 116819 times.
252244 if(fall <= termv && needFall)
8101 {
8102 116819 inair = true;
8103
3/4
✓ Branch 0 taken 47047 times.
✓ Branch 1 taken 69772 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47047 times.
116819 if(fall != 0 || hoverclk>0)
8104 69772 jumping++;
8105
8106 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8107
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 163 times.
116819 if(get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8108 {
8109
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8110
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8111 // Extra checks if Smart Screen Scrolling is enabled
8112
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8113 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8114
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8115 {
8116 591 fall = jumping = 0; // Bumped his head
8117
8118 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8119
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8120 {
8121 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8122 110 }
8123 591 }
8124 116656 }
8125 else
8126 {
8127
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 163 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 163 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 163 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 163 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 163 times.
✗ Branch 15 not taken.
326 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8128
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 163 times.
163 || ((y<=0) &&
8129 // Extra checks if Smart Screen Scrolling is enabled
8130 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8131 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8132 && fall < 0)
8133 {
8134 fall = jumping = 0; // Bumped his head
8135 y -= y.getInt()%8; //fix coords
8136 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8137 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8138 {
8139 checkdamagecombos(x+4, x+12, y-1, y-1);
8140 }
8141 }
8142 }
8143
8144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116819 times.
116819 if(hoverclk > 0)
8145 {
8146 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8147 {
8148 --hoverclk;
8149 }
8150
8151 if(!hoverclk && !ladderx && !laddery)
8152 {
8153 fall += gravity3;
8154 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8155 }
8156 }
8157
5/12
✓ Branch 0 taken 84979 times.
✓ Branch 1 taken 31840 times.
✓ Branch 2 taken 47744 times.
✓ Branch 3 taken 37235 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47744 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
116819 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8158 {
8159 int32_t itemid = current_item_id(itype_hoverboots);
8160 if(hoverclk < 0)
8161 hoverclk = -hoverclk;
8162 else
8163 {
8164 fall = jumping = 0;
8165 if(itemsbuf[itemid].misc1)
8166 hoverclk = itemsbuf[itemid].misc1;
8167 else
8168 {
8169 hoverclk = 1;
8170 hoverflags |= HOV_INF;
8171 }
8172
8173
8174 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8175 }
8176 if(itemsbuf[itemid].wpn)
8177 decorations.add(new dHover(x, y, dHOVER, 0));
8178 }
8179
4/8
✓ Branch 0 taken 116819 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116819 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116819 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116819 times.
116819 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8180 {
8181 116819 fall += gravity3;
8182
8183 116819 }
8184 116819 }
8185 252244 }
8186 else // Topdown gravity
8187 {
8188
4/4
✓ Branch 0 taken 13997902 times.
✓ Branch 1 taken 7010629 times.
✓ Branch 2 taken 7009781 times.
✓ Branch 3 taken 848 times.
21008531 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8189
4/4
✓ Branch 0 taken 13997902 times.
✓ Branch 1 taken 7010629 times.
✓ Branch 2 taken 7009781 times.
✓ Branch 3 taken 848 times.
21008531 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8190
4/4
✓ Branch 0 taken 7006721 times.
✓ Branch 1 taken 14001810 times.
✓ Branch 2 taken 14005718 times.
✓ Branch 3 taken 21012439 times.
21008531 if(z>0||fakez>0)
8191 {
8192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3908 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28007528 switch(action)
8193 {
8194 case swimming:
8195 {
8196 diveclk=0;
8197 action=walking; FFCore.setHeroAction(walking);
8198
8199 break;
8200 }
8201 case waterhold1:
8202 {
8203 action=landhold1; FFCore.setHeroAction(landhold1);
8204 break;
8205 }
8206
8207 case waterhold2:
8208 {
8209 action=landhold2; FFCore.setHeroAction(landhold2);
8210 break;
8211 }
8212
8213 default:
8214 3908 break;
8215 }
8216 3908 }
8217
8218
2/2
✓ Branch 0 taken 16982 times.
✓ Branch 1 taken 21016347 times.
21033329 for(int32_t j=0; j<chainlinks.Count(); j++)
8219 {
8220 16982 chainlinks.spr(j)->z=z;
8221 16982 chainlinks.spr(j)->fakez=fakez;
8222 16982 }
8223
8224
2/2
✓ Branch 0 taken 21011836 times.
✓ Branch 1 taken 4511 times.
21016347 if(Lwpns.idFirst(wHookshot)>-1)
8225 {
8226 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8227 4511 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8228 4511 }
8229
8230
2/2
✓ Branch 0 taken 21011615 times.
✓ Branch 1 taken 4732 times.
21016347 if(Lwpns.idFirst(wHSHandle)>-1)
8231 {
8232 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8233 4732 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8234 4732 }
8235
8236
3/4
✓ Branch 0 taken 7006721 times.
✓ Branch 1 taken 14009626 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7006721 times.
21016347 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8237 {
8238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7006721 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7006721 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8239 {
8240
2/2
✓ Branch 0 taken 7006678 times.
✓ Branch 1 taken 43 times.
7006721 if(fall > 0)
8241 {
8242
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 6 times.
43 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8243 6 sfx(WAV_ZN1SPLASH,x.getInt());
8244
8245 43 stomping = true;
8246 43 }
8247 7006721 }
8248 7006721 z = fall = 0;
8249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7006721 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7006721 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8250 {
8251 7006721 jumping = 0;
8252
2/2
✓ Branch 0 taken 7006170 times.
✓ Branch 1 taken 551 times.
7006721 if(check_pitslide(true) == -1)
8253 {
8254 7006170 hoverclk = 0;
8255 7006170 hoverflags = 0;
8256 7006170 }
8257
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
551 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8258 {
8259
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8260 {
8261 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8262 }
8263 17 }
8264 7006721 }
8265 7006721 }
8266
3/4
✓ Branch 0 taken 7010629 times.
✓ Branch 1 taken 14005718 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7010629 times.
21016347 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8267 {
8268
3/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 7006721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3908 times.
7010629 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8269 {
8270
1/2
✓ Branch 0 taken 7006721 times.
✗ Branch 1 not taken.
7006721 if(fakefall > 0)
8271 {
8272 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8273 sfx(WAV_ZN1SPLASH,x.getInt());
8274
8275 stomping = true;
8276 }
8277 7006721 }
8278 7010629 fakez = fakefall = 0;
8279
3/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 7006721 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3908 times.
7010629 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8280 {
8281 7006721 jumping = 0;
8282
2/2
✓ Branch 0 taken 7006170 times.
✓ Branch 1 taken 551 times.
7006721 if(check_pitslide(true) == -1)
8283 {
8284 7006170 hoverclk = 0;
8285 7006170 hoverflags = 0;
8286 7006170 }
8287
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
551 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8288 {
8289
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8290 {
8291 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8292 }
8293 17 }
8294 7006721 }
8295 7010629 }
8296
8/10
✓ Branch 0 taken 7010606 times.
✓ Branch 1 taken 14005741 times.
✓ Branch 2 taken 7010606 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7002859 times.
✓ Branch 5 taken 7747 times.
✓ Branch 6 taken 7006744 times.
✓ Branch 7 taken 7006744 times.
✓ Branch 8 taken 7006744 times.
✗ Branch 9 not taken.
21016347 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8297 {
8298
4/6
✓ Branch 0 taken 2731 times.
✓ Branch 1 taken 1154 times.
✓ Branch 2 taken 2731 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2731 times.
14009603 if(fall != 0 || fakefall != 0 || hoverclk>0)
8299 1154 jumping++;
8300
8301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3885 times.
3885 if(hoverclk > 0)
8302 {
8303 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8304 {
8305 --hoverclk;
8306 }
8307
8308 if(!hoverclk)
8309 {
8310 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8311 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8312 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8313 }
8314 }
8315
9/16
✓ Branch 0 taken 3377 times.
✓ Branch 1 taken 508 times.
✓ Branch 2 taken 2741 times.
✓ Branch 3 taken 636 times.
✓ Branch 4 taken 2741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1144 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1144 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1144 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3885 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3885 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8316 {
8317 if(hoverclk < 0)
8318 hoverclk = -hoverclk;
8319 else
8320 {
8321 fall = 0;
8322 fakefall = 0;
8323 int32_t itemid = current_item_id(itype_hoverboots);
8324 if(itemsbuf[itemid].misc1)
8325 hoverclk = itemsbuf[itemid].misc1;
8326 else
8327 {
8328 hoverclk = 1;
8329 hoverflags |= HOV_INF;
8330 }
8331 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8332 }
8333 decorations.add(new dHover(x, y, dHOVER, 0));
8334 }
8335 else
8336 {
8337
3/6
✓ Branch 0 taken 3885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3885 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3885 times.
3885 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8338
3/6
✓ Branch 0 taken 3885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3885 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3885 times.
✗ Branch 5 not taken.
3885 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8339 }
8340 3885 }
8341
1/2
✓ Branch 0 taken 7010629 times.
✗ Branch 1 not taken.
7010629 if (fakez<0) fakez = 0;
8342
1/2
✓ Branch 0 taken 7010629 times.
✗ Branch 1 not taken.
7010629 if (z<0) z = 0;
8343 }
8344
8345
1/2
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
7262873 if(drunkclk)
8346 {
8347 --drunkclk;
8348 }
8349
8350
1/2
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
7262873 if(lstunclock > 0)
8351 {
8352 // also cancel Hero's attack
8353 attackclk = 0;
8354
8355 if( FFCore.getHeroAction() != stunned )
8356 {
8357 tempaction=action; //update so future checks won't do this
8358 //action=freeze; //setting this makes the player invincible while stunned -V
8359 FFCore.setHeroAction(stunned);
8360 }
8361 --lstunclock;
8362 }
8363 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8364 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262873 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262873 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8366 {
8367 action=tempaction; FFCore.setHeroAction(tempaction);
8368 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8369 //action=none; FFCore.setHeroAction(none);
8370 }
8371
8372
1/2
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
7262873 if( lbunnyclock > 0 )
8373 {
8374 --lbunnyclock;
8375 }
8376
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 7260948 times.
7262873 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8377 {
8378 1925 int32_t itemid = current_item_id(itype_pearl);
8379
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8380 {
8381
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8382 1 lbunnyclock = 0;
8383 123 }
8384
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8385 {
8386 1 lbunnyclock = -1;
8387 1 }
8388 1925 }
8389
1/2
✓ Branch 0 taken 7260948 times.
✗ Branch 1 not taken.
7260948 else if(lbunnyclock == -1) //dmap-caused bunny effect
8390 {
8391 lbunnyclock = 0;
8392 }
8393
8394
13/18
✓ Branch 0 taken 7252316 times.
✓ Branch 1 taken 10557 times.
✓ Branch 2 taken 6337799 times.
✓ Branch 3 taken 914517 times.
✓ Branch 4 taken 6337799 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6337799 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1206 times.
✓ Branch 9 taken 6336593 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1206 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 6335990 times.
✓ Branch 15 taken 1809 times.
✓ Branch 16 taken 48588 times.
✓ Branch 17 taken 6286808 times.
7262873 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8395
2/2
✓ Branch 0 taken 6335396 times.
✓ Branch 1 taken 594 times.
6335990 && action != gothit)
8396 {
8397
2/3
✓ Branch 0 taken 2854719 times.
✓ Branch 1 taken 3432089 times.
✗ Branch 2 not taken.
6286808 switch(dir)
8398 {
8399 case up:
8400 case down:
8401 2854719 x=(x.getInt()+4)&0xFFF8;
8402 2854719 break;
8403
8404 case left:
8405 case right:
8406 3432089 y=(y.getInt()+4)&0xFFF8;
8407 3432089 break;
8408 }
8409 6286808 }
8410
8411
4/4
✓ Branch 0 taken 120611 times.
✓ Branch 1 taken 7142262 times.
✓ Branch 2 taken 43192 times.
✓ Branch 3 taken 77419 times.
7262873 if((watch==true) && clockclk)
8412 {
8413 43192 --clockclk;
8414
8415
2/2
✓ Branch 0 taken 43078 times.
✓ Branch 1 taken 114 times.
43192 if(!clockclk)
8416 {
8417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(cheat_superman==false)
8418 {
8419 114 setClock(false);
8420 114 }
8421
8422 114 watch=false;
8423
8424
2/2
✓ Branch 0 taken 58368 times.
✓ Branch 1 taken 114 times.
58482 for(int32_t i=0; i<eMAXGUYS; i++)
8425 {
8426
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 58368 times.
58374 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8427 {
8428 6 addenemy(0,0,i,0);
8429 6 }
8430 58368 }
8431 114 }
8432 43192 }
8433
8434
3/4
✓ Branch 0 taken 7258141 times.
✓ Branch 1 taken 4732 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7258141 times.
7262873 if(hookshot_frozen || switch_hooked)
8435 {
8436
3/4
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 221 times.
4732 if(hookshot_used || switch_hooked)
8437 {
8438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4511 times.
4511 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8439 4511 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8440
8441
3/4
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3888 times.
4511 if(pull_hero || switch_hooked)
8442 {
8443
3/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 563 times.
623 if(hs_switcher || switch_hooked)
8444 {
8445 60 hs_fix = false;
8446
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(switchhookclk)
8447 {
8448 60 --switchhookclk;
8449
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59 times.
60 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8450 {
8451
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8452 reset_hookshot();
8453 else
8454 {
8455 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8456 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8457
8458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1) //Switching combos
8459 {
8460 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8461 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8462 {
8463 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8464 for(int q = max_layer; q > -1; --q)
8465 {
8466 if(!(hooked_layerbits & (1<<q)))
8467 continue; //non-switching layer
8468 mapscr* scr = FFCore.tempScreens[q];
8469 newcombo const& cmb = combobuf[scr->data[targpos]];
8470 int32_t srcfl = scr->sflag[targpos];
8471 newcombo const& comb2 = combobuf[scr->data[plpos]];
8472 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8473 //{Check push status
8474 bool isFakePush = false;
8475 if(cmb.type == cSWITCHHOOK)
8476 {
8477 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8478 isFakePush = true;
8479 }
8480 bool isPush = isFakePush;
8481 if(!isPush) switch(srcfl)
8482 {
8483 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8484 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8485 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8486 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8487 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8488 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8489 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8490 isPush = true;
8491 }
8492 if(!isPush) switch(cmb.flag)
8493 {
8494 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8495 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8496 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8497 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8498 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8499 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8500 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8501 isPush = true;
8502 }
8503 if(srcfl==mfPUSHED) isPush = false;
8504 //}
8505 if(cmb.type == cSWITCHHOOK) //custom flags and such
8506 {
8507 if(cmb.usrflags&cflag3) //Breaks on swap
8508 {
8509 int32_t it = -1;
8510 int32_t thedropset = -1;
8511 if(cmb.usrflags&cflag4) //drop item
8512 {
8513 if(cmb.usrflags&cflag5)
8514 it = cmb.attribytes[2];
8515 else
8516 {
8517 it = select_dropitem(cmb.attribytes[2]);
8518 thedropset = cmb.attribytes[2];
8519 }
8520 }
8521
8522 breakable* br = new breakable(x, y, zfix(0),
8523 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8524 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8525 br->switch_hooked = true;
8526 decorations.add(br);
8527 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8528 hooked_undercombos[q] = -1;
8529
8530 if(cmb.usrflags&cflag6)
8531 {
8532 scr->data[targpos]++;
8533 }
8534 else
8535 {
8536 scr->data[targpos] = scr->undercombo;
8537 scr->cset[targpos] = scr->undercset;
8538 if(cmb.usrflags&cflag2)
8539 scr->sflag[targpos] = 0;
8540 }
8541 }
8542 else if(isPush)
8543 {
8544 //Simulate a block clicking into place
8545 movingblock mtemp;
8546 mtemp.clear();
8547 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8548 mtemp.dir = getPushDir(scr->sflag[targpos]);
8549 if(mtemp.dir < 0)
8550 mtemp.dir = getPushDir(cmb.flag);
8551 mtemp.clk = 1;
8552 mtemp.force_many = isFakePush;
8553 mtemp.no_icy = true;
8554 mtemp.animate(0);
8555 if((mtemp.bhole || mtemp.trigger)
8556 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8557 || comb2.flag == mfBLOCKTRIGGER
8558 || comb2.flag == mfBLOCKHOLE))
8559 {
8560 scr->data[targpos] = scr->undercombo;
8561 scr->cset[targpos] = scr->undercset;
8562 scr->sflag[targpos] = 0;
8563 }
8564 else
8565 {
8566 scr->data[targpos] = c;
8567 scr->cset[targpos] = cs;
8568 if(cmb.usrflags&cflag2)
8569 scr->sflag[targpos] = fl;
8570 else
8571 scr->sflag[targpos] = 0;
8572 }
8573 }
8574 else
8575 {
8576 scr->data[plpos] = scr->data[targpos];
8577 scr->cset[plpos] = scr->cset[targpos];
8578 if(cmb.usrflags&cflag2)
8579 scr->sflag[plpos] = scr->sflag[targpos];
8580 scr->data[targpos] = c;
8581 scr->cset[targpos] = cs;
8582 if(cmb.usrflags&cflag2)
8583 scr->sflag[targpos] = fl;
8584 }
8585 }
8586 else if(isCuttableType(cmb.type)) //Break and drop effects
8587 {
8588 int32_t breakcs = scr->cset[targpos];
8589 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8590 {
8591 scr->data[targpos]++;
8592 }
8593 else
8594 {
8595 scr->data[targpos] = scr->undercombo;
8596 scr->cset[targpos] = scr->undercset;
8597 scr->sflag[targpos] = 0;
8598 }
8599
8600 int32_t it = -1;
8601 int32_t thedropset = -1;
8602 if(isCuttableItemType(cmb.type)) //Drop an item
8603 {
8604 if ( (cmb.usrflags&cflag2) )
8605 {
8606 if(cmb.usrflags&cflag11)
8607 it = cmb.attribytes[1];
8608 else
8609 {
8610 it = select_dropitem(cmb.attribytes[1]);
8611 thedropset = cmb.attribytes[1];
8612 }
8613 }
8614 else
8615 {
8616 it = select_dropitem(12);
8617 thedropset = 12;
8618 }
8619 }
8620
8621 byte breaksfx = 0;
8622 if(get_qr(qr_MORESOUNDS)) //SFX
8623 {
8624 if (cmb.usrflags&cflag3)
8625 {
8626 breaksfx = cmb.attribytes[2];
8627 }
8628 else if(isBushType(cmb.type)
8629 || isFlowersType(cmb.type)
8630 || isGrassType(cmb.type))
8631 {
8632 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8633 }
8634 }
8635
8636 //Clipping sprite
8637 int16_t decotype = (cmb.usrflags & cflag1) ?
8638 ((cmb.usrflags & cflag10)
8639 ? (cmb.attribytes[0])
8640 : (-1))
8641 : (0);
8642 if(decotype > 3) decotype = 0;
8643 if(!decotype)
8644 decotype = (isBushType(cmb.type) ? 1
8645 : (isFlowersType(cmb.type) ? 2
8646 : (isGrassType(cmb.type) ? 3
8647 : ((cmb.usrflags & cflag1) ? -1
8648 : -2))));
8649
8650 breakable* br = new breakable(x, y, zfix(0),
8651 cmb, breakcs, it, thedropset, breaksfx,
8652 decotype, cmb.attribytes[0], switchhookclk);
8653 br->switch_hooked = true;
8654 decorations.add(br);
8655 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8656 hooked_undercombos[q] = -1;
8657 }
8658 else //Unknown type, just swap combos.
8659 {
8660 if(isPush)
8661 {
8662 //Simulate a block clicking into place
8663 movingblock mtemp;
8664 mtemp.clear();
8665 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8666 mtemp.dir = getPushDir(scr->sflag[targpos]);
8667 if(mtemp.dir < 0)
8668 mtemp.dir = getPushDir(cmb.flag);
8669 mtemp.clk = 1;
8670 mtemp.animate(0);
8671 if(mtemp.bhole || mtemp.trigger)
8672 {
8673 scr->data[targpos] = scr->undercombo;
8674 scr->cset[targpos] = scr->undercset;
8675 scr->sflag[targpos] = 0;
8676 }
8677 else
8678 {
8679 scr->data[targpos] = c;
8680 scr->cset[targpos] = cs;
8681 scr->sflag[targpos] = 0;
8682 }
8683 }
8684 else
8685 {
8686 scr->data[plpos] = scr->data[targpos];
8687 scr->cset[plpos] = scr->cset[targpos];
8688 scr->data[targpos] = c;
8689 scr->cset[targpos] = cs;
8690 }
8691 }
8692 }
8693 if(switchhook_cost_item > -1)
8694 paymagiccost(switchhook_cost_item);
8695 zfix tx = x, ty = y;
8696 //Position the player at the combo
8697 x = COMBOX(targpos);
8698 y = COMBOY(targpos);
8699 dir = oppositeDir[dir];
8700 if(w && hw)
8701 {
8702 //Calculate chain shift
8703 zfix dx = (x-tx);
8704 zfix dy = (y-ty);
8705 if(w->dir < 4)
8706 {
8707 if(w->dir & 2)
8708 dx = 0;
8709 else dy = 0;
8710 }
8711 //Position the hook head at the handle
8712 w->x = hw->x + dx;
8713 w->y = hw->y + dy;
8714 w->dir = oppositeDir[w->dir];
8715 w->doAutoRotate(true);
8716 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8717 w->flip ^= hflip;
8718 //Position the handle appropriately
8719 hw->x = x-(hw->x-tx);
8720 hw->y = y-(hw->y-ty);
8721 hw->dir = oppositeDir[hw->dir];
8722 hw->doAutoRotate(true);
8723 hw->flip ^= hflip;
8724 //Move chains
8725 for(int32_t j=0; j<chainlinks.Count(); j++)
8726 {
8727 chainlinks.spr(j)->x += dx;
8728 chainlinks.spr(j)->y += dy;
8729 }
8730 }
8731 hooked_combopos = plpos; //flip positions
8732 }
8733 else reset_hookshot();
8734 }
8735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object) //Switching an object
8736 {
8737
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(switchhook_cost_item > -1)
8738 paymagiccost(switchhook_cost_item);
8739 1 zfix tx = x, ty = y;
8740 //Position the player at the object
8741 1 x = switching_object->x;
8742 1 y = switching_object->y;
8743 1 dir = oppositeDir[dir];
8744 //Position the object at the player
8745 1 switching_object->x = tx;
8746 1 switching_object->y = ty;
8747
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8748 switching_object->dir = oppositeDir[switching_object->dir];
8749 1 solid_update(false);
8750 1 switching_object->solid_update(false);
8751
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(item* it = dynamic_cast<item*>(switching_object))
8752 {
8753 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8754 {
8755 movefairynew2(it->x, it->y, *it);
8756 }
8757 }
8758
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(w && hw) //!TODO No fucking clue if diagonals work
8759 {
8760 //Calculate chain shift
8761 1 zfix dx = (x-tx);
8762 1 zfix dy = (y-ty);
8763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
8764 {
8765
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
8766 1 dx = 0;
8767 else dy = 0;
8768 1 }
8769 //Position the hook head at the handle
8770 1 w->x = hw->x + dx;
8771 1 w->y = hw->y + dy;
8772 1 w->dir = oppositeDir[w->dir];
8773 1 w->doAutoRotate(true);
8774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8775 1 w->flip ^= hflip;
8776 1 w->solid_update(false);
8777 //Position the handle appropriately
8778 1 hw->x = x-(hw->x-tx);
8779 1 hw->y = y-(hw->y-ty);
8780 1 hw->dir = oppositeDir[hw->dir];
8781 1 hw->doAutoRotate(true);
8782 1 hw->flip ^= hflip;
8783 1 hw->solid_update(false);
8784 //Move chains
8785
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
8786 {
8787 5 chainlinks.spr(j)->x += dx;
8788 5 chainlinks.spr(j)->y += dy;
8789 5 }
8790 1 }
8791 1 }
8792 }
8793 1 }
8794
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 else if(!switchhookclk)
8795 {
8796 1 reset_hookshot();
8797 1 }
8798 60 }
8799 else reset_hookshot();
8800 60 }
8801 else
8802 {
8803 sprite *t;
8804 int32_t i;
8805
8806
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 579 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 563 times.
579 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8807 {
8808 /* do nothing */
8809 16 }
8810
8811 563 t = Lwpns.spr(i);
8812
8813
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 563 times.
1705 for(i=0; i<Lwpns.Count(); i++)
8814 {
8815 1142 sprite *s = Lwpns.spr(i);
8816
8817
2/2
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 563 times.
1142 if(s->id==wHookshot)
8818 {
8819
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 500 times.
563 if (abs((s->y) - y) >= 1)
8820 {
8821
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 38 times.
63 if((s->y)>y)
8822 {
8823 38 y+=4;
8824
8825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(Lwpns.idFirst(wHSHandle)!=-1)
8826 {
8827 38 t->y+=4;
8828 38 }
8829
8830 38 hs_starty+=4;
8831 38 }
8832
8833
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 25 times.
63 if((s->y)<y)
8834 {
8835 25 y-=4;
8836
8837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Lwpns.idFirst(wHSHandle)!=-1)
8838 {
8839 25 t->y-=4;
8840 25 }
8841
8842 25 hs_starty-=4;
8843 25 }
8844 63 }
8845 else
8846 {
8847 500 y = (s->y);
8848 }
8849
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 63 times.
563 if (abs((s->x) - x) >= 1)
8850 {
8851
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 338 times.
500 if((s->x)>x)
8852 {
8853 338 x+=4;
8854
8855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338 times.
338 if(Lwpns.idFirst(wHSHandle)!=-1)
8856 {
8857 338 t->x+=4;
8858 338 }
8859
8860 338 hs_startx+=4;
8861 338 }
8862
8863
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 162 times.
500 if((s->x)<x)
8864 {
8865 162 x-=4;
8866
8867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(Lwpns.idFirst(wHSHandle)!=-1)
8868 {
8869 162 t->x-=4;
8870 162 }
8871
8872 162 hs_startx-=4;
8873 162 }
8874 500 }
8875 else
8876 {
8877 63 x = (s->x);
8878 }
8879 563 }
8880 1142 }
8881 }
8882 623 }
8883 4511 }
8884 else
8885 {
8886 221 Lwpns.del(Lwpns.idFirst(wHSHandle));
8887 221 reset_hookshot();
8888 }
8889
8890
1/2
✓ Branch 0 taken 4732 times.
✗ Branch 1 not taken.
4732 if(hs_fix)
8891 {
8892 if(dir==up)
8893 {
8894 y=int32_t(y+7)&0xF0;
8895 }
8896
8897 if(dir==down)
8898 {
8899 y=int32_t(y+7)&0xF0;
8900 }
8901
8902 if(dir==left)
8903 {
8904 x=int32_t(x+7)&0xF0;
8905 }
8906
8907 if(dir==right)
8908 {
8909 x=int32_t(x+7)&0xF0;
8910 }
8911
8912 hs_fix=false;
8913 }
8914
8915 4732 }
8916
8917
2/2
✓ Branch 0 taken 575604 times.
✓ Branch 1 taken 6687269 times.
7262873 if(!get_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8918 {
8919
2/2
✓ Branch 0 taken 3475 times.
✓ Branch 1 taken 6683794 times.
6687269 if(DrunkrLbtn())
8920 3475 selectNextBWpn(SEL_LEFT);
8921
2/2
✓ Branch 0 taken 6679899 times.
✓ Branch 1 taken 3895 times.
6683794 else if(DrunkrRbtn())
8922 3895 selectNextBWpn(SEL_RIGHT);
8923 6687269 }
8924
4/4
✓ Branch 0 taken 585695 times.
✓ Branch 1 taken 6677178 times.
✓ Branch 2 taken 575040 times.
✓ Branch 3 taken 10655 times.
7262873 if (get_qr(qr_SELECTAWPN) && get_qr(qr_USE_EX1_EX2_INVENTORYSWAP))
8925 {
8926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (rEx3btn())
8927 selectNextAWpn(SEL_LEFT);
8928
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (rEx4btn())
8929 1 selectNextAWpn(SEL_RIGHT);
8930 10655 }
8931
8932
2/2
✓ Branch 0 taken 7262453 times.
✓ Branch 1 taken 420 times.
7262873 if(rPbtn())
8933 {
8934
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 417 times.
420 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8935 417 onViewMap();
8936 420 }
8937
2/2
✓ Branch 0 taken 3083806 times.
✓ Branch 1 taken 7262873 times.
10346679 for(int32_t i=0; i<Lwpns.Count(); i++)
8938 {
8939 3083806 weapon *w = ((weapon*)Lwpns.spr(i));
8940
8941
6/6
✓ Branch 0 taken 3058527 times.
✓ Branch 1 taken 25279 times.
✓ Branch 2 taken 2739369 times.
✓ Branch 3 taken 319158 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 2739296 times.
3083806 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8942 344510 addsparkle(i);
8943 3083806 }
8944
8945
1/2
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
7262873 if(Lwpns.idCount(wPhantom))
8946 {
8947 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
8948 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
8949 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
8950 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
8951 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
8952 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
8953 }
8954
8955 // Pay magic cost for Byrna beams
8956
8957 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8958
2/2
✓ Branch 0 taken 7262800 times.
✓ Branch 1 taken 73 times.
7262873 if(Lwpns.idCount(wCByrna))
8959 {
8960 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8961 73 int32_t itemid = ew->parentitem;
8962
8963
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8964 {
8965 for(int32_t i=0; i<Lwpns.Count(); i++)
8966 {
8967 weapon *w = ((weapon*)Lwpns.spr(i));
8968
8969 if(w->id==wCByrna)
8970 {
8971 w->dead=1;
8972 }
8973
8974 }
8975 //kill the sound effect for the orbits -Z 14FEB2019
8976 stop_sfx(itemsbuf[itemid].usesound);
8977 }
8978 73 else paymagiccost(itemid);
8979 73 }
8980
8981
3/4
✓ Branch 0 taken 7258965 times.
✓ Branch 1 taken 3908 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7258965 times.
7262873 if(z==0&&fakez==0)
8982 {
8983 7258965 switchblock_z = 0;
8984
1/2
✓ Branch 0 taken 7258965 times.
✗ Branch 1 not taken.
7258965 if(switchblock_offset)
8985 {
8986 switchblock_offset=false;
8987 yofs += 8;
8988 }
8989 7258965 }
8990
2/2
✓ Branch 0 taken 252244 times.
✓ Branch 1 taken 7010629 times.
7262873 if(!isSideViewHero())
8991 {
8992 7010629 int32_t tx = x.getInt()+8,
8993 7010629 ty = y.getInt()+8;//(bigHitbox?8:12);
8994
4/4
✓ Branch 0 taken 7010382 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 7010161 times.
7010629 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8995 {
8996
2/2
✓ Branch 0 taken 7010161 times.
✓ Branch 1 taken 21030483 times.
28040644 for(int32_t q = 0; q < 3; ++q)
8997 {
8998
4/4
✓ Branch 0 taken 14020322 times.
✓ Branch 1 taken 7010161 times.
✓ Branch 2 taken 2477596 times.
✓ Branch 3 taken 11542726 times.
21030483 if(q && !tmpscr2[q-1].valid) continue;
8999 9487757 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
9000
3/4
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 9486790 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
9487757 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
9001 int32_t b = 1;
9002 if(tx&8) b <<= 2;
9003 if(ty&8) b <<= 1;
9004 b |= (b<<4); //check equivalent effect flag too
9005 if((cmb.walk&b)==b) //solid and effecting
9006 {
9007 if(z==0&&fakez==0)
9008 {
9009 if(cmb.usrflags&cflag10)
9010 {
9011 if(!switchblock_offset)
9012 {
9013 switchblock_offset=true;
9014 yofs -= 8;
9015 }
9016 }
9017 else
9018 {
9019 if(switchblock_offset)
9020 {
9021 switchblock_offset=false;
9022 yofs += 8;
9023 }
9024 }
9025 }
9026 if(cmb.attributes[2]>0 && switchblock_z>=0)
9027 {
9028 if(z==0&&fakez==0)
9029 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
9030 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
9031 {
9032 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
9033 }
9034 }
9035 else switchblock_z = -1;
9036 break;
9037 }
9038 }
9039 7010161 }
9040 7010629 }
9041 7262873 ClearhitHeroUIDs(); //clear them before we advance.
9042 7262873 checkhit();
9043
9044 7262873 bool forcedeath = dying_flags&DYING_FORCED;
9045 7262873 bool norev = (dying_flags&DYING_NOREV);
9046
4/6
✓ Branch 0 taken 7262873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 7262677 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 196 times.
7262873 if(forcedeath || (game->get_life()<=0 && !immortal))
9047 {
9048
1/2
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
196 if(forcedeath)
9049 game->set_life(0);
9050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
196 if(!norev)
9051
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 50176 times.
50372 for(size_t slot = 0; slot < 256; ++slot)
9052 {
9053
1/2
✓ Branch 0 taken 50176 times.
✗ Branch 1 not taken.
50176 if(size_t bind = game->get_bottle_slot(slot))
9054 {
9055 bottletype const* bt = &QMisc.bottle_types[bind-1];
9056 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9057 continue;
9058 word toFill[3] = { 0 };
9059 for(size_t q = 0; q < 3; ++q)
9060 {
9061 char c = bt->counter[q];
9062 if(c > -1)
9063 {
9064 if(bt->flags & (1<<q))
9065 {
9066 toFill[q] = (bt->amount[q]==100)
9067 ? game->get_maxcounter(c)
9068 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9069 }
9070 else toFill[q] = bt->amount[q];
9071 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9072 {
9073 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9074 }
9075 }
9076 }
9077 if(bt->flags & BTFLAG_CURESWJINX)
9078 {
9079 swordclk = 0;
9080 verifyAWpn();
9081 }
9082 if(bt->flags & BTFLAG_CUREITJINX)
9083 itemclk = 0;
9084 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9085 {
9086 int32_t itemid = find_bottle_for_slot(slot,true);
9087 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9088 if(itemid > -1)
9089 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9090 for(size_t q = 0; q < 20; ++q)
9091 do_death_refill_waitframe();
9092 double inc = max/60.0; //1 second
9093 double xtra[3]{ 0 };
9094 for(size_t q = 0; q < 60; ++q)
9095 {
9096 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9097 sfx(QMisc.miscsfx[sfxREFILL]);
9098 for(size_t j = 0; j < 3; ++j)
9099 {
9100 xtra[j] += inc;
9101 word f = floor(xtra[j]);
9102 xtra[j] -= f;
9103 if(toFill[j] > f)
9104 {
9105 toFill[j] -= f;
9106 game->change_counter(f,bt->counter[j]);
9107 }
9108 else if(toFill[j])
9109 {
9110 game->change_counter(toFill[j],bt->counter[j]);
9111 toFill[j] = 0;
9112 }
9113 }
9114 do_death_refill_waitframe();
9115 }
9116 for(size_t j = 0; j < 3; ++j)
9117 {
9118 if(toFill[j])
9119 {
9120 game->change_counter(toFill[j],bt->counter[j]);
9121 toFill[j] = 0;
9122 }
9123 }
9124 for(size_t q = 0; q < 20; ++q)
9125 do_death_refill_waitframe();
9126 }
9127 game->set_bottle_slot(slot,bt->next_type);
9128 if(game->get_life() > 0)
9129 {
9130 dying_flags = 0;
9131 forcedeath = false;
9132 break; //Revived! Stop drinking things...
9133 }
9134 }
9135 50372 }
9136
9137
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 186 times.
196 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9138 {
9139
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
10 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9140 {
9141 // So scripts can have one frame to handle hp zero events
9142
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(norev || false == (last_hurrah = !last_hurrah))
9143 {
9144 dying_flags = 0;
9145 drunkclk=0;
9146 lstunclock = 0;
9147 is_conveyor_stunned = 0;
9148 FFCore.setHeroAction(dying);
9149 FFCore.deallocateAllArrays(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9150 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
9151 ALLOFF(true,true);
9152 GameFlags |= GAMEFLAG_NO_F6;
9153 if(!debug_enabled)
9154 {
9155 Paused=false;
9156 }
9157 if(!get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9158 {
9159 FFCore.runOnDeathEngine();
9160 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9161 }
9162 Playing = false;
9163 heroDeathAnimation();
9164 if(get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9165 {
9166 Playing = true;
9167 FFCore.runOnDeathEngine();
9168 FFCore.deallocateAllArrays(ScriptType::Player, SCRIPT_PLAYER_DEATH);
9169 Playing = false;
9170 }
9171 GameFlags &= ~GAMEFLAG_NO_F6;
9172 ALLOFF(true,true);
9173 return true;
9174 }
9175 10 }
9176 10 }
9177 else //2.50.x
9178 {
9179 // So scripts can have one frame to handle hp zero events
9180
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 93 times.
186 if(false == (last_hurrah = !last_hurrah))
9181 {
9182 93 drunkclk=0;
9183 93 heroDeathAnimation();
9184
9185 93 return true;
9186 }
9187 }
9188 103 }
9189 7262677 else last_hurrah=false;
9190
9191
2/2
✓ Branch 0 taken 7229737 times.
✓ Branch 1 taken 33043 times.
7262780 if(swordclk>0)
9192 {
9193 33043 --swordclk;
9194
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 32887 times.
33043 if(!swordclk) verifyAWpn();
9195 33043 }
9196
2/2
✓ Branch 0 taken 7258722 times.
✓ Branch 1 taken 4058 times.
7262780 if(itemclk>0)
9197 4058 --itemclk;
9198
1/2
✓ Branch 0 taken 7262780 times.
✗ Branch 1 not taken.
7262780 if(shieldjinxclk>0)
9199 --shieldjinxclk;
9200
9201
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 7262488 times.
7262780 if(inwallm)
9202 {
9203 292 attackclk=0;
9204 292 herostep();
9205
9206
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 289 times.
292 if(CarryHero()==false)
9207 3 restart_level();
9208
9209 292 solid_update(false);
9210 292 return false;
9211 }
9212
9213
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7262487 times.
7262488 if(ewind_restart)
9214 {
9215 1 attackclk=0;
9216 1 restart_level();
9217 1 xofs=0;
9218 1 action=none; FFCore.setHeroAction(none);
9219 1 ewind_restart=false;
9220 1 solid_update(false);
9221 1 return false;
9222 }
9223
9224
2/2
✓ Branch 0 taken 7256160 times.
✓ Branch 1 taken 6327 times.
7262487 if(hopclk)
9225 {
9226 6327 action=hopping; FFCore.setHeroAction(hopping);
9227 6327 }
9228
2/2
✓ Branch 0 taken 7261997 times.
✓ Branch 1 taken 490 times.
7262487 if(fallclk)
9229 {
9230 490 action=falling; FFCore.setHeroAction(falling);
9231 490 }
9232
9233 7262487 handle_passive_buttons();
9234
2/2
✓ Branch 0 taken 7262271 times.
✓ Branch 1 taken 216 times.
7262487 if(liftclk)
9235 {
9236
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(lift_wpn)
9237 {
9238 216 action=lifting; FFCore.setHeroAction(lifting);
9239 216 }
9240 else
9241 {
9242 liftclk = 0;
9243 tliftclk = 0;
9244 }
9245 216 }
9246
2/2
✓ Branch 0 taken 7261394 times.
✓ Branch 1 taken 877 times.
7262271 else if(lift_wpn)
9247 {
9248 877 handle_lift(false);
9249 877 }
9250
9251
9252 // get user input or do other animation
9253 7262487 freeze_guys=false; // reset this flag, set it again if holding
9254
9255
14/16
✓ Branch 0 taken 7210092 times.
✓ Branch 1 taken 52395 times.
✓ Branch 2 taken 7196308 times.
✓ Branch 3 taken 13784 times.
✓ Branch 4 taken 7195658 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 7195267 times.
✓ Branch 7 taken 391 times.
✓ Branch 8 taken 7195267 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7195267 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7176511 times.
✓ Branch 13 taken 18756 times.
✓ Branch 14 taken 7176489 times.
✓ Branch 15 taken 22 times.
7262487 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9256 {
9257 22 holdclk=0;
9258 22 }
9259
9260 7262487 active_shield_id = refreshActiveShield();
9261 7262487 bool sh = active_shield_id > -1;
9262 7262487 itemdata const& shield = itemsbuf[active_shield_id];
9263 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9264 7262487 shield_forcedir = -1;
9265
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 7262487 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7262487 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9266 {
9267 shield_forcedir = dir;
9268 }
9269
1/2
✓ Branch 0 taken 7262487 times.
✗ Branch 1 not taken.
7262487 if(sh != shield_active) //Toggle active shield on/off
9270 {
9271 shield_active = sh;
9272 if(sh) //Toggle active shield on
9273 {
9274 sfx(shield.usesound2); //'Activate' sfx
9275 }
9276 }
9277
9278 7262487 bool isthissolid = false;
9279
11/12
✓ Branch 0 taken 66724 times.
✓ Branch 1 taken 1041 times.
✓ Branch 2 taken 640 times.
✓ Branch 3 taken 164223 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 66179 times.
✓ Branch 6 taken 6894784 times.
✓ Branch 7 taken 52096 times.
✓ Branch 8 taken 490 times.
✓ Branch 9 taken 6327 times.
✓ Branch 10 taken 9767 times.
✓ Branch 11 taken 216 times.
7262487 switch(action)
9280 {
9281 case gothit:
9282
2/2
✓ Branch 0 taken 50603 times.
✓ Branch 1 taken 1493 times.
52096 if(attackclk)
9283
2/2
✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 200 times.
1693 if(!doattack())
9284 {
9285 200 attackclk=spins=0;
9286 200 tapping=false;
9287 200 }
9288
9289 52096 break;
9290
9291 case drowning:
9292 case lavadrowning:
9293 case sidedrowning:
9294 {
9295 640 herostep(); // maybe this line should be elsewhere?
9296
9297 //!DROWN
9298 // Helpful comment to find drowning -Dimi
9299
9300 640 drop_liftwpn();
9301
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 10 times.
640 if(--drownclk==0)
9302 {
9303 10 action=none; FFCore.setHeroAction(none);
9304
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 int32_t water = drownCombo ? drownCombo : iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9305
9306 10 std::vector<int32_t> &ev = FFCore.eventData;
9307 10 ev.clear();
9308 10 ev.push_back(water*10000);
9309
9310 10 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9311 10 water = ev[0]/10000;
9312 10 newcombo const& watercmb = combobuf[water];
9313
9314 10 int32_t damage = 4;
9315
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
10 if (watercmb.type == cWATER)
9316 9 damage = watercmb.attributes[0]/10000L;
9317 1 else water = 0;
9318
9319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(cheat_superman && damage > 0)
9320 damage = 0;
9321
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(damage)
9322 10 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9323 10 drownCombo = 0;
9324 10 go_respawn_point();
9325 10 hclk=48;
9326 10 }
9327
9328 640 break;
9329 }
9330 case falling:
9331 {
9332 490 herostep();
9333 490 pitfall();
9334 490 break;
9335 }
9336 case freeze:
9337 case sideswimfreeze:
9338 case scrolling:
9339 164223 break;
9340
9341 case casting:
9342 case sideswimcasting:
9343 {
9344 if(magicitem==-1)
9345 {
9346 action=none; FFCore.setHeroAction(none);
9347 }
9348
9349 break;
9350 }
9351 case landhold1:
9352 case landhold2:
9353 {
9354
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 65671 times.
66179 if(--holdclk <= 0)
9355 {
9356 //restart music
9357
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
508 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9358 28 playLevelMusic();
9359
9360 508 action=none; FFCore.setHeroAction(none);
9361 508 post_item_collect();
9362 508 }
9363 else
9364 65671 freeze_guys=true;
9365
9366 66179 break;
9367 }
9368 case waterhold1:
9369 case waterhold2:
9370 case sidewaterhold1:
9371 case sidewaterhold2:
9372 {
9373 1041 diveclk=0;
9374
9375
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1032 times.
1041 if(--holdclk <= 0)
9376 {
9377 //restart music
9378
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9379 playLevelMusic();
9380
9381 9 SetSwim();
9382 9 post_item_collect();
9383 9 }
9384 else
9385 1032 freeze_guys=true;
9386
9387 1041 break;
9388 }
9389 case hopping:
9390 {
9391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6327 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6327 if(DRIEDLAKE)
9392 {
9393 action=none; FFCore.setHeroAction(none);
9394 hopclk = 0;
9395 diveclk = 0;
9396 break;
9397 }
9398
9399 6327 do_hopping();
9400 6327 break;
9401 }
9402 case inwind:
9403 {
9404 9767 int32_t i=Lwpns.idFirst(wWind);
9405
9406
2/2
✓ Branch 0 taken 9634 times.
✓ Branch 1 taken 133 times.
9767 if(i<0)
9407 {
9408 133 bool exit=false;
9409
9410
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 67 times.
133 if(whirlwind==255)
9411 {
9412 66 exit=true;
9413 66 }
9414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y<=0 && dir==up) y=-1;
9415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(y>=160 && dir==down) y=161;
9416
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 else if(x<=0 && dir==left) x=-1;
9417
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
67 else if(x>=240 && dir==right) x=241;
9418 else exit=true;
9419
9420
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 if(exit)
9421 {
9422 66 action=none; FFCore.setHeroAction(none);
9423 66 xofs=0;
9424 66 whirlwind=0;
9425 66 lstep=0;
9426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if ( dontdraw < 2 ) dontdraw=0;
9427 66 set_respawn_point();
9428 66 }
9429 133 }
9430 /*
9431 else if (((weapon*)Lwpns.spr(i))->dead==1)
9432 {
9433 whirlwind=255;
9434 }
9435 */
9436 else
9437 {
9438 9634 x=Lwpns.spr(i)->x;
9439 9634 y=Lwpns.spr(i)->y;
9440 9634 dir=Lwpns.spr(i)->dir;
9441 }
9442 }
9443 9767 break;
9444 case lifting:
9445 216 handle_lift();
9446 216 break;
9447
9448 case sideswimming:
9449 case sideswimattacking:
9450 case sideswimhit:
9451 case swimhit:
9452 case swimming:
9453 {
9454
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66724 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66724 if(DRIEDLAKE)
9455 {
9456 action=none; FFCore.setHeroAction(none);
9457 hopclk=0;
9458 break;
9459 }
9460
9461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66724 times.
66724 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9462
9463
4/4
✓ Branch 0 taken 33330 times.
✓ Branch 1 taken 33394 times.
✓ Branch 2 taken 259 times.
✓ Branch 3 taken 33071 times.
66724 if((frame&1) && !shouldbreak)
9464 33071 herostep();
9465
9466
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 66724 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66724 times.
✓ Branch 4 taken 2282 times.
✓ Branch 5 taken 64442 times.
69006 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9467
4/6
✓ Branch 0 taken 64442 times.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
66724 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9468
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
2282 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9469
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2282 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2282 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2282 times.
66724 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9470
4/4
✓ Branch 0 taken 65457 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 65457 times.
✓ Branch 3 taken 1267 times.
66724 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9471 {
9472
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9473
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9474 {
9475 12 hopclk=0;
9476 12 diveclk=0;
9477
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9478 else {action=attacking; FFCore.setHeroAction(attacking);}
9479 12 hopdir=-1;
9480 12 }
9481 1267 }
9482
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 66197 times.
66724 if (shouldbreak) break;
9483
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 66185 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
66197 if (action == swimming || action == sideswimming || action == sideswimattacking)
9484 {
9485 66185 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66185 times.
66185 if (combobuf[watercheck].usrflags&cflag2)
9487 {
9488 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9489 {
9490 onpassivedmg = true;
9491 if (damageovertimeclk == 0)
9492 {
9493 int32_t curhp = game->get_life();
9494 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9495 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9496 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9497 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9498 {
9499 hclk = 48;
9500 hitdir = -1;
9501 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9502 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9503 }
9504 }
9505 if (combobuf[watercheck].attribytes[1] > 0)
9506 {
9507 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9508 else --damageovertimeclk;
9509 }
9510 else damageovertimeclk = 0;
9511 }
9512 else damageovertimeclk = 0;
9513 }
9514 66185 else damageovertimeclk = 0;
9515 //combobuf[watercheck].attributes[0]
9516 66185 }
9517
9518 66197 }
9519 [[fallthrough]];
9520 default:
9521 // call the main movement routine
9522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6960981 times.
6960981 if(get_qr(qr_NEW_HERO_MOVEMENT2))
9523 {
9524 if(premove())
9525 movehero();
9526 }
9527 6960981 else moveheroOld();
9528 6960981 }
9529
9530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262487 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262487 if(shield_forcedir > -1 && action != rafting)
9531 dir = shield_forcedir;
9532
9533
9534 // check for ladder removal
9535
2/2
✓ Branch 0 taken 914485 times.
✓ Branch 1 taken 6348002 times.
7262487 if(diagonalMovement)
9536 {
9537
2/2
✓ Branch 0 taken 914449 times.
✓ Branch 1 taken 36 times.
914485 if(ladderx+laddery)
9538 {
9539
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(ladderdir==up)
9540 {
9541 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9542 {
9543 reset_ladder();
9544 }
9545 }
9546 else
9547 {
9548
9/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33 times.
36 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9549 {
9550 3 reset_ladder();
9551 3 }
9552 }
9553 36 }
9554 914485 }
9555 else
9556 {
9557
4/4
✓ Branch 0 taken 248446 times.
✓ Branch 1 taken 6099556 times.
✓ Branch 2 taken 141079 times.
✓ Branch 3 taken 107367 times.
6348002 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9558 {
9559 6240635 reset_ladder();
9560 6240635 }
9561 }
9562
9563
2/2
✓ Branch 0 taken 7238208 times.
✓ Branch 1 taken 24279 times.
7262487 if(!get_qr(qr_OLD_RESPAWN_POINTS)) //needs to happen after ladder removal so the respawn point is set when laddering over multiple 1 tile gaps.
9564 24279 set_respawn_point(false); //Keep the 'last safe location' updated!
9565
9566
2/2
✓ Branch 0 taken 1538 times.
✓ Branch 1 taken 7260949 times.
7262487 if(ilswim)
9567 1538 landswim++;
9568 7260949 else landswim=0;
9569
9570
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 7262481 times.
7262487 if(hopclk!=0xFF) ilswim=false;
9571
9572
3/4
✓ Branch 0 taken 15878 times.
✓ Branch 1 taken 7246609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15878 times.
7262487 if((!loaded_guys) && (frame - newscr_clk >= 1))
9573 {
9574
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 15864 times.
15878 if(tmpscr->room==rGANON)
9575 {
9576 14 ganon_intro();
9577 14 }
9578 else
9579 {
9580 15864 loadguys();
9581 }
9582 15878 }
9583
9584
2/2
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 7245827 times.
7262487 if(frame - newscr_clk >= 2)
9585 {
9586 7245827 loadenemies();
9587 7245827 }
9588
9589 // check lots of other things
9590 7262487 checkscroll();
9591
9592
6/8
✓ Branch 0 taken 7252787 times.
✓ Branch 1 taken 9700 times.
✓ Branch 2 taken 7252157 times.
✓ Branch 3 taken 630 times.
✓ Branch 4 taken 7252157 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7252157 times.
7262487 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9593 {
9594 7252157 checkspecial();
9595 7252157 checkitems();
9596 7252157 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9597
2/2
✓ Branch 0 taken 24780 times.
✓ Branch 1 taken 7227377 times.
7252157 if(get_qr(qr_OLD_LOCKBLOCK_COLLISION))
9598 {
9599 7227377 oldchecklockblock();
9600 7227377 oldcheckbosslockblock();
9601 7227377 }
9602
2/2
✓ Branch 0 taken 155403 times.
✓ Branch 1 taken 7096754 times.
7252157 if(get_qr(qr_OLD_CHEST_COLLISION))
9603 {
9604 7096754 oldcheckchest(cCHEST);
9605 7096754 oldcheckchest(cLOCKEDCHEST);
9606 7096754 oldcheckchest(cBOSSCHEST);
9607 7096754 }
9608 7252157 checkpushblock();
9609 7252157 checkswordtap();
9610
9611
2/2
✓ Branch 0 taken 4732 times.
✓ Branch 1 taken 7247425 times.
7252157 if(hookshot_frozen==false)
9612 {
9613 7247425 checkspecial2(&lsave);
9614 7247425 }
9615
9616
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7252148 times.
7252157 if(action==won)
9617 {
9618 9 return true;
9619 }
9620 7252148 }
9621
9622 // Somehow Hero was displaced from the fairy flag...
9623
3/6
✓ Branch 0 taken 18756 times.
✓ Branch 1 taken 7243722 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18756 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7262478 if(fairyclk && action != freeze && action != sideswimfreeze)
9624 {
9625 fairyclk = holdclk = refill_why = 0;
9626 }
9627
9628
3/4
✓ Branch 0 taken 7262478 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7241946 times.
✓ Branch 3 taken 20532 times.
7262478 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9629 {
9630 20532 tmpscr->timedwarptics--;
9631
9632
2/2
✓ Branch 0 taken 20466 times.
✓ Branch 1 taken 66 times.
20532 if(tmpscr->timedwarptics==0)
9633 {
9634 66 activated_timed_warp=true;
9635
9636
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 3 times.
66 if(tmpscr->flags4 & fTIMEDDIRECT)
9637 {
9638 3 didpit=true;
9639 3 pitx=x;
9640 3 pity=y;
9641 3 }
9642
9643 66 int32_t index2 = 0;
9644
9645
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9646
9647 66 sdir = dir;
9648 66 dowarp(1,index2);
9649 66 }
9650 20532 }
9651
9652 7262478 bool awarp = false;
9653 //!DIMI: Global Combo Effects (AUTO STUFF)
9654
2/2
✓ Branch 0 taken 71112 times.
✓ Branch 1 taken 7262478 times.
7333590 for(auto& p : slopes)
9655 {
9656 71112 slope_object& s = p.second;
9657 71112 s.updateslope(); //sets old x/y poses
9658 }
9659
2/2
✓ Branch 0 taken 7262477 times.
✓ Branch 1 taken 1278196102 times.
1285458579 for(int32_t i=0; i<176; ++i)
9660 {
9661
2/2
✓ Branch 0 taken 4075632 times.
✓ Branch 1 taken 5125011301 times.
5129086933 for(int32_t layer=0; layer<7; ++layer)
9662 {
9663
2/2
✓ Branch 0 taken 3846815199 times.
✓ Branch 1 taken 1278196102 times.
5125011301 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9664 5125011301 newcombo const& cmb = combobuf[cid];
9665
9666
2/2
✓ Branch 0 taken 28529424 times.
✓ Branch 1 taken 5096481877 times.
5125011301 if(!get_qr(qr_AUTOCOMBO_ANY_LAYER))
9667 {
9668
2/2
✓ Branch 0 taken 3822361408 times.
✓ Branch 1 taken 1274120469 times.
5096481877 if(layer > 2) break;
9669
4/4
✓ Branch 0 taken 1274120469 times.
✓ Branch 1 taken 2548240939 times.
✓ Branch 2 taken 23374912 times.
✓ Branch 3 taken 1250745557 times.
3822361408 if (layer == 1 && !get_qr(qr_AUTOCOMBO_LAYER_1)) continue;
9670
4/4
✓ Branch 0 taken 1274120469 times.
✓ Branch 1 taken 1297495382 times.
✓ Branch 2 taken 23374912 times.
✓ Branch 3 taken 1250745557 times.
2571615851 if (layer == 2 && !get_qr(qr_AUTOCOMBO_LAYER_2)) continue;
9671 1320870294 }
9672 1349399718 int32_t ind=0;
9673
9674 //AUTOMATIC TRIGGER CODE
9675
2/2
✓ Branch 0 taken 1349385632 times.
✓ Branch 1 taken 14086 times.
1349399718 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9676 {
9677 14086 do_trigger_combo(layer, i);
9678 14086 }
9679
9680 //AUTO WARP CODE
9681
2/2
✓ Branch 0 taken 19463 times.
✓ Branch 1 taken 1349380255 times.
1349399718 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9682 {
9683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1349380255 times.
1349380255 if(cmb.type==cAWARPA)
9684 {
9685 awarp=true;
9686 ind=0;
9687 }
9688
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1349380254 times.
1349380255 else if(cmb.type==cAWARPB)
9689 {
9690 1 awarp=true;
9691 1 ind=1;
9692 1 }
9693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1349380254 times.
1349380254 else if(cmb.type==cAWARPC)
9694 {
9695 awarp=true;
9696 ind=2;
9697 }
9698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1349380254 times.
1349380254 else if(cmb.type==cAWARPD)
9699 {
9700 awarp=true;
9701 ind=3;
9702 }
9703
1/2
✓ Branch 0 taken 1349380254 times.
✗ Branch 1 not taken.
1349380254 else if(cmb.type==cAWARPR)
9704 {
9705 awarp=true;
9706 ind=zc_oldrand()%4;
9707 }
9708 1349380255 }
9709
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1349399717 times.
1349399718 if(awarp)
9710 {
9711
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9712 {
9713 didpit=true;
9714 pitx=x;
9715 pity=y;
9716 }
9717
9718 1 sdir = dir;
9719 1 dowarp(1,ind);
9720 1 break;
9721 }
9722 1349399717 }
9723
2/2
✓ Branch 0 taken 1278196101 times.
✓ Branch 1 taken 1 times.
1278196102 if(awarp) break;
9724 1278196101 }
9725
9726 7262478 awarp=false;
9727
9728 7262478 word c = tmpscr->numFFC();
9729
2/2
✓ Branch 0 taken 7262437 times.
✓ Branch 1 taken 228079452 times.
235341889 for(word i=0; i<c; i++)
9730 {
9731 228079452 int32_t ind=0;
9732
9733 228079452 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9734
9735
1/2
✓ Branch 0 taken 228079452 times.
✗ Branch 1 not taken.
228079452 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9736 {
9737 do_trigger_combo_ffc(i);
9738 }
9739
9740
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 228075544 times.
228079452 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9741 {
9742
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 228075538 times.
228075544 if(cmb.type==cAWARPA)
9743 {
9744 6 awarp=true;
9745 6 ind=0;
9746 6 }
9747
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 228075508 times.
228075538 else if(cmb.type==cAWARPB)
9748 {
9749 30 awarp=true;
9750 30 ind=1;
9751 30 }
9752
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 228075506 times.
228075508 else if(cmb.type==cAWARPC)
9753 {
9754 2 awarp=true;
9755 2 ind=2;
9756 2 }
9757
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 228075503 times.
228075506 else if(cmb.type==cAWARPD)
9758 {
9759 3 awarp=true;
9760 3 ind=3;
9761 3 }
9762
1/2
✓ Branch 0 taken 228075503 times.
✗ Branch 1 not taken.
228075503 else if(cmb.type==cAWARPR)
9763 {
9764 awarp=true;
9765 ind=zc_oldrand()%4;
9766 }
9767 228075544 }
9768
9769
2/2
✓ Branch 0 taken 228079411 times.
✓ Branch 1 taken 41 times.
228079452 if(awarp)
9770 {
9771
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(tmpscr->flags5&fDIRECTAWARP)
9772 {
9773 didpit=true;
9774 pitx=x;
9775 pity=y;
9776 }
9777
9778 41 sdir = dir;
9779 41 dowarp(1,ind);
9780 41 break;
9781 }
9782 228079411 }
9783 7262478 zfix dx, dy;
9784
7/8
✓ Branch 0 taken 252235 times.
✓ Branch 1 taken 7010243 times.
✓ Branch 2 taken 125395 times.
✓ Branch 3 taken 126840 times.
✓ Branch 4 taken 576 times.
✓ Branch 5 taken 124819 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 576 times.
7262478 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9785 {
9786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if (slide_slope(this, dx, dy, slopeid))
9787 {
9788 576 onplatid = 5;
9789
2/4
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 576 times.
576 if (dx || dy) push_move(dx, dy);
9790 576 }
9791 576 }
9792
2/2
✓ Branch 0 taken 7261756 times.
✓ Branch 1 taken 722 times.
7262478 if (onplatid <= 0) slopeid = 0;
9793 722 else --onplatid;
9794
2/2
✓ Branch 0 taken 5666002 times.
✓ Branch 1 taken 1596476 times.
7262478 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9795
5/6
✓ Branch 0 taken 958 times.
✓ Branch 1 taken 7262478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 958 times.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 7262478 times.
7263436 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9796 {
9797
2/4
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 958 times.
958 if (check_slope(this, true) && !toogam)
9798 {
9799 958 slope_info const& s = get_slope(this, true).get_info();
9800 958 bool staircheck = false;
9801
4/4
✓ Branch 0 taken 856 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 854 times.
✓ Branch 3 taken 2 times.
958 if (s.slope() != slopeid && slopeid) staircheck = true;
9802
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 8 times.
958 if (onplatform) staircheck = true;
9803 958 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9804
9805
3/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
958 if (dx || dy)
9806 {
9807 958 int32_t pushret = push_move(dx,dy);
9808
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9809
4/4
✓ Branch 0 taken 856 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 854 times.
✓ Branch 3 taken 2 times.
958 if (s.slope() != slopeid && slopeid) staircheck = true;
9810
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if (onplatform) staircheck = true;
9811
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 104 times.
958 if(sideview_mode() && slopeid)
9812 104 onplatid = 5;
9813
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if (pushret == 1)
9814 {
9815 dx = -1;
9816 dy = 0;
9817 slope_push_int(s, this, dx, dy, staircheck);
9818 push_move(dx,dy);
9819 }
9820
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if (pushret == 2)
9821 {
9822 dx = 0;
9823 dy = -1;
9824 slope_push_int(s, this, dx, dy, staircheck);
9825 push_move(dx,dy);
9826 }
9827 958 }
9828 958 }
9829 958 }
9830
9831
2/2
✓ Branch 0 taken 7262273 times.
✓ Branch 1 taken 205 times.
7262478 if(ffwarp)
9832 {
9833
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 126 times.
205 if(ffpit)
9834 {
9835 126 ffpit=false;
9836 126 didpit=true;
9837 126 pitx=x;
9838 126 pity=y;
9839 126 }
9840
9841 205 ffwarp=false;
9842 205 dowarp(1,0);
9843 205 }
9844
9845 //Hero->WarpEx
9846
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 7262462 times.
7262478 if ( FFCore.warpex[wexActive] )
9847 {
9848 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9849 16 FFCore.warpex[wexActive] = 0;
9850 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9851
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9852 {
9853 144 temp_warpex[q] = FFCore.warpex[q];
9854 144 FFCore.warpex[q] = 0;
9855 144 }
9856 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9857 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9858 16 }
9859
9860
4/4
✓ Branch 0 taken 3909 times.
✓ Branch 1 taken 7258569 times.
✓ Branch 2 taken 19615 times.
✓ Branch 3 taken 22244 times.
7262478 if(z == 0 || !get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
9861 {
9862 // walk through bombed doors and fake walls
9863 7280813 bool walk=false;
9864 7280813 int32_t dtype=dBOMBED;
9865
9866
2/2
✓ Branch 0 taken 7053563 times.
✓ Branch 1 taken 183366 times.
7280813 if(pushing>=24) dtype=dWALK;
9867
9868
16/18
✓ Branch 0 taken 3733226 times.
✓ Branch 1 taken 3503703 times.
✓ Branch 2 taken 3666647 times.
✓ Branch 3 taken 66579 times.
✓ Branch 4 taken 3666647 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3661074 times.
✓ Branch 7 taken 5573 times.
✓ Branch 8 taken 3658499 times.
✓ Branch 9 taken 2575 times.
✓ Branch 10 taken 3657848 times.
✓ Branch 11 taken 651 times.
✓ Branch 12 taken 3647997 times.
✓ Branch 13 taken 9851 times.
✓ Branch 14 taken 3647997 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 86416 times.
✓ Branch 17 taken 3734413 times.
7236929 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9869 {
9870
12/14
✓ Branch 0 taken 101365 times.
✓ Branch 1 taken 3633048 times.
✓ Branch 2 taken 601182 times.
✓ Branch 3 taken 3031866 times.
✓ Branch 4 taken 601176 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 601176 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 601176 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 562021 times.
✓ Branch 11 taken 562015 times.
✓ Branch 12 taken 39019 times.
✓ Branch 13 taken 136 times.
3734413 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y<=32 && tmpscr->door[0]==dtype)
9871 {
9872 136 walk=true;
9873 136 dir=up;
9874 136 }
9875
9876
12/14
✓ Branch 0 taken 101365 times.
✓ Branch 1 taken 3633036 times.
✓ Branch 2 taken 397004 times.
✓ Branch 3 taken 3236032 times.
✓ Branch 4 taken 498277 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 498277 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 498277 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 474265 times.
✓ Branch 11 taken 474173 times.
✓ Branch 12 taken 23897 times.
✓ Branch 13 taken 115 times.
3734401 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x.getInt()>112&&x.getInt()<128:x.getInt()==120) && y>=128 && tmpscr->door[1]==dtype)
9877 {
9878 115 walk=true;
9879 115 dir=down;
9880 115 }
9881
9882
9/14
✓ Branch 0 taken 101365 times.
✓ Branch 1 taken 3632852 times.
✓ Branch 2 taken 43753 times.
✓ Branch 3 taken 3589099 times.
✓ Branch 4 taken 58898 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58898 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58898 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 58794 times.
✓ Branch 13 taken 58794 times.
3734217 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[2]==dtype)
9883 {
9884 104 walk=true;
9885 104 dir=left;
9886 104 }
9887
9888
9/14
✓ Branch 0 taken 3546632 times.
✓ Branch 1 taken 101365 times.
✓ Branch 2 taken 35923 times.
✓ Branch 3 taken 3510709 times.
✓ Branch 4 taken 72922 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72922 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 72922 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 72803 times.
✓ Branch 13 taken 72803 times.
3647997 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y.getInt()>72&&y.getInt()<88:y.getInt()==80) && tmpscr->door[3]==dtype)
9889 {
9890 119 walk=true;
9891 119 dir=right;
9892 119 }
9893 3583631 }
9894
9895
2/2
✓ Branch 0 taken 7258505 times.
✓ Branch 1 taken 474 times.
7258979 if(walk)
9896 {
9897 474 hclk=0;
9898 474 drawguys=false;
9899
9900
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 172 times.
474 if(dtype==dWALK)
9901 {
9902 172 sfx(tmpscr->secretsfx);
9903 172 }
9904
9905 474 action=none; FFCore.setHeroAction(none);
9906 474 attackclk = 0;
9907 474 stepforward(29, true);
9908 474 action=scrolling; FFCore.setHeroAction(scrolling);
9909 474 pushing=false;
9910 474 }
9911 7258979 }
9912
9913
4/6
✓ Branch 0 taken 135056 times.
✓ Branch 1 taken 7143538 times.
✓ Branch 2 taken 135056 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 135056 times.
7278594 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9914 {
9915
1/2
✓ Branch 0 taken 135056 times.
✗ Branch 1 not taken.
135056 if(heart_beep)
9916 {
9917 135056 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9918 135056 }
9919 else
9920 {
9921 if ( heart_beep_timer == -1 )
9922 {
9923 heart_beep_timer = 70;
9924 }
9925
9926 if ( heart_beep_timer > 0 )
9927 {
9928 --heart_beep_timer;
9929 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9930 }
9931 else
9932 {
9933 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9934 }
9935 }
9936 135056 }
9937 else
9938 {
9939
2/2
✓ Branch 0 taken 16788 times.
✓ Branch 1 taken 7127422 times.
7143538 if ( heart_beep_timer > -2 )
9940 {
9941 7127422 heart_beep_timer = -1;
9942 7127422 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9943 7127422 }
9944 }
9945
9946
2/2
✓ Branch 0 taken 7278463 times.
✓ Branch 1 taken 803 times.
7279266 if(rSbtn())
9947 {
9948 803 int32_t tmp_subscr_clk = frame;
9949
9950 803 int32_t save_type = 0;
9951
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 795 times.
✗ Branch 3 not taken.
803 switch(lsave)
9952 {
9953 case 0:
9954 {
9955
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 754 times.
795 if( FFCore.runActiveSubscreenScriptEngine() )
9956 {
9957 41 break;
9958 }
9959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 else if ( !stopSubscreenFalling() )
9960 {
9961 754 conveyclk=3;
9962 754 dosubscr();
9963 754 newscr_clk += frame - tmp_subscr_clk;
9964 754 }
9965 754 break;
9966 }
9967
9968
9969 case 2:
9970 save_type = 1;
9971 [[fallthrough]];
9972 case 1:
9973
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9974 7 trigger_save(combobuf[last_savepoint_id]);
9975 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9976 7 break;
9977 }
9978 803 }
9979
9980
2/2
✓ Branch 0 taken 377425 times.
✓ Branch 1 taken 6901839 times.
7279264 if (!checkstab() )
9981 {
9982 /*
9983 for(int32_t q=0; q<176; q++)
9984 {
9985 set_bit(screengrid,q,0);
9986 }
9987
9988 for(int32_t q=0; q<MAXFFCS; q++)
9989 set_bit(ffcgrid, q, 0);
9990 */
9991 6901839 }
9992
9993 7279264 check_conveyor();
9994 7279264 PhantomsCleanup();
9995 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9996
2/2
✓ Branch 0 taken 7213480 times.
✓ Branch 1 taken 65784 times.
7279264 if(attack==wHammer)
9997 {
9998
6/8
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 65043 times.
✓ Branch 2 taken 741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 741 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 739 times.
65784 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9999 {
10000
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 247 times.
739 switch(dir) //Hero's dir
10001 {
10002 case up:
10003
5/10
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 117 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 117 times.
✗ Branch 9 not taken.
117 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
10004 117 break;
10005
10006 case down:
10007
5/10
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
10008 162 break;
10009
10010 case left:
10011
5/10
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 213 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 213 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 213 times.
✗ Branch 9 not taken.
213 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
10012 213 break;
10013
10014 case right:
10015
5/10
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 247 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 247 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 247 times.
✗ Branch 9 not taken.
247 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
10016 247 break;
10017 }
10018
10019 739 }
10020 65784 }
10021
10022 7279264 handleSpotlights();
10023
10024
1/2
✓ Branch 0 taken 7279264 times.
✗ Branch 1 not taken.
7279264 if(getOnSideviewLadder())
10025 {
10026 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
10027 {
10028 setOnSideviewLadder(false);
10029 }
10030 else if(CANFORCEFACEUP)
10031 {
10032 setDir(up);
10033 }
10034 }
10035
2/2
✓ Branch 0 taken 228698 times.
✓ Branch 1 taken 7050566 times.
7279264 if (justmoved > 0) --justmoved;
10036
10037 7279264 return false;
10038 7279659 }
10039
10040 2321 bool HeroClass::push_pixel(zfix dx, zfix dy)
10041 {
10042
2/4
✓ Branch 0 taken 2321 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2321 times.
✗ Branch 3 not taken.
2321 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
10043
3/4
✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 1176 times.
✓ Branch 2 taken 1145 times.
✗ Branch 3 not taken.
2321 if(dx && dy)
10044 {
10045 bool r = push_pixel(0,dy);
10046 bool r2 = push_pixel(dx,0);
10047 return r && r2;
10048 }
10049
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 1785 times.
2321 if(dx < 0)
10050 {
10051
1/2
✓ Branch 0 taken 536 times.
✗ Branch 1 not taken.
1072 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
10052
1/2
✓ Branch 0 taken 536 times.
✗ Branch 1 not taken.
536 || solpush_walkflag(x+dx,y+8,1,this)
10053
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 536 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 69 times.
536 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
10054 {
10055 536 x += dx;
10056 536 return true;
10057 }
10058 return false;
10059 }
10060
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 1176 times.
1785 else if(dx > 0)
10061 {
10062
1/2
✓ Branch 0 taken 609 times.
✗ Branch 1 not taken.
1218 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10063
1/2
✓ Branch 0 taken 609 times.
✗ Branch 1 not taken.
609 || solpush_walkflag(x+15+dx,y+8,1,this)
10064
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 609 times.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 60 times.
609 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10065 {
10066 609 x += dx;
10067 609 return true;
10068 }
10069 return false;
10070 }
10071
2/2
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 453 times.
1176 else if(dy < 0)
10072 {
10073
1/2
✓ Branch 0 taken 723 times.
✗ Branch 1 not taken.
1446 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10074
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 125 times.
723 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10075 {
10076 723 y += dy;
10077 723 return true;
10078 }
10079 return false;
10080 }
10081
1/2
✓ Branch 0 taken 453 times.
✗ Branch 1 not taken.
453 else if(dy > 0)
10082 {
10083
1/2
✓ Branch 0 taken 453 times.
✗ Branch 1 not taken.
906 if(!(solpush_walkflag(x,y+15+dy,2,this)
10084
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 358 times.
453 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10085 {
10086 453 y += dy;
10087 453 return true;
10088 }
10089 return false;
10090 }
10091 return false;
10092 2321 }
10093 958 int32_t HeroClass::push_move(zfix dx, zfix dy)
10094 {
10095 958 int32_t ret = 0;
10096
4/4
✓ Branch 0 taken 1145 times.
✓ Branch 1 taken 1182 times.
✓ Branch 2 taken 958 times.
✓ Branch 3 taken 1369 times.
2327 while(dx || dy)
10097 {
10098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1369 times.
1369 if(check_pitslide() != -1)
10099 break;
10100
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 1176 times.
1369 if(dy)
10101 {
10102
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 848 times.
1176 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10103 1176 dy -= cy;
10104
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!push_pixel(0,cy))
10105 {
10106 dy = 0;
10107 ret |= 2;
10108 }
10109 1176 }
10110
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1145 times.
1369 if(dx)
10111 {
10112
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 848 times.
1145 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10113 1145 dx -= cx;
10114
1/2
✓ Branch 0 taken 1145 times.
✗ Branch 1 not taken.
1145 if(!push_pixel(cx,0))
10115 {
10116 dx = 0;
10117 ret |= 1;
10118 }
10119 1145 }
10120 }
10121 958 return ret;
10122 }
10123
10124 7262770 bool HeroClass::setSolid(bool set)
10125 {
10126
1/2
✓ Branch 0 taken 7262770 times.
✗ Branch 1 not taken.
7262770 bool actual = set && !toogam; //not solid when noclipping
10127 7262770 bool ret = solid_object::setSolid(actual);
10128 7262770 solid = set;
10129 7262770 return ret;
10130 }
10131
10132 2424 void HeroClass::solid_push(solid_object* obj)
10133 {
10134
1/2
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
2424 if(obj == this) return; //can't push self
10135
10136 2424 zfix dx, dy;
10137 2424 int32_t hdir = -1;
10138 2424 solid_push_int(obj,dx,dy,hdir);
10139
10140
2/4
✓ Branch 0 taken 2424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2424 times.
✗ Branch 3 not taken.
2424 if(!dx && !dy) return;
10141
10142 obj->doContactDamage(hdir);
10143
10144 bool t = obj->getTempNonsolid();
10145 obj->setTempNonsolid(true);
10146
10147 push_move(dx,dy);
10148
10149 obj->setTempNonsolid(t);
10150 2424 }
10151
10152 // A routine used exclusively by startwpn,
10153 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10154 774 void HeroClass::deselectbombs(int32_t super)
10155 {
10156
6/10
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 762 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 762 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 762 times.
774 if ( get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10157
2/6
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
762 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10158 {
10159
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
762 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10160 762 Bwpn = Bweapon(temp);
10161 762 directItemB = directItem;
10162 762 game->bwpn = temp;
10163 762 }
10164
10165 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10166 {
10167 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10168 Xwpn = Bweapon(temp);
10169 directItemX = directItem;
10170 game->xwpn = temp;
10171 }
10172 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10173 {
10174 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10175 Ywpn = Bweapon(temp);
10176 directItemY = directItem;
10177 game->ywpn = temp;
10178 }
10179 else
10180 {
10181 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10182 Awpn = Bweapon(temp);
10183 directItemA = directItem;
10184 game->awpn = temp;
10185 }
10186 774 }
10187
10188 int32_t potion_life=0;
10189 int32_t potion_magic=0;
10190
10191 6961750 bool HeroClass::onWater(bool drownonly)
10192 {
10193 6961750 int32_t water = 0;
10194 6961750 int32_t types[4] = {0};
10195 6961750 int32_t x1 = x+4, x2 = x+11,
10196 6961750 y1 = y+9, y2 = y+15;
10197
2/2
✓ Branch 0 taken 237979 times.
✓ Branch 1 taken 6723771 times.
6961750 if (get_qr(qr_SMARTER_WATER))
10198 {
10199
4/4
✓ Branch 0 taken 1628 times.
✓ Branch 1 taken 236351 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1314 times.
239296 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10200
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 156 times.
1628 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10201
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 155 times.
1472 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10202 1317 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10203 237979 }
10204 else
10205 {
10206 6723771 types[0] = COMBOTYPE(x1,y1);
10207
10208
2/2
✓ Branch 0 taken 6695558 times.
✓ Branch 1 taken 28213 times.
6723771 if(MAPFFCOMBO(x1,y1))
10209 28213 types[0] = FFCOMBOTYPE(x1,y1);
10210
10211 6723771 types[1] = COMBOTYPE(x1,y2);
10212
10213
2/2
✓ Branch 0 taken 6696904 times.
✓ Branch 1 taken 26867 times.
6723771 if(MAPFFCOMBO(x1,y2))
10214 26867 types[1] = FFCOMBOTYPE(x1,y2);
10215
10216 6723771 types[2] = COMBOTYPE(x2,y1);
10217
10218
2/2
✓ Branch 0 taken 6695538 times.
✓ Branch 1 taken 28233 times.
6723771 if(MAPFFCOMBO(x2,y1))
10219 28233 types[2] = FFCOMBOTYPE(x2,y1);
10220
10221 6723771 types[3] = COMBOTYPE(x2,y2);
10222
10223
2/2
✓ Branch 0 taken 6696848 times.
✓ Branch 1 taken 26923 times.
6723771 if(MAPFFCOMBO(x2,y2))
10224 26923 types[3] = FFCOMBOTYPE(x2,y2);
10225
10226 6723771 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10227
2/2
✓ Branch 0 taken 6695744 times.
✓ Branch 1 taken 28027 times.
6723771 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10228 28027 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10229
10230
5/6
✓ Branch 0 taken 135364 times.
✓ Branch 1 taken 6588407 times.
✓ Branch 2 taken 128081 times.
✓ Branch 3 taken 7283 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 121286 times.
6845057 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10231
4/4
✓ Branch 0 taken 121426 times.
✓ Branch 1 taken 6655 times.
✓ Branch 2 taken 121286 times.
✓ Branch 3 taken 140 times.
128081 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10232 121286 water = typec;
10233 }
10234
2/2
✓ Branch 0 taken 6839150 times.
✓ Branch 1 taken 122600 times.
6961750 if(water > 0)
10235 {
10236
1/2
✓ Branch 0 taken 122600 times.
✗ Branch 1 not taken.
122600 if(!drownonly) return true;
10237
4/8
✓ Branch 0 taken 69981 times.
✓ Branch 1 taken 52619 times.
✓ Branch 2 taken 69981 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 69981 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
122600 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10238 {
10239 52619 return true;
10240 }
10241 69981 }
10242 6909131 return false;
10243 6961750 }
10244
10245 bool HeroClass::mirrorBonk()
10246 {
10247 zfix tx = x, ty = y, tz = z;
10248 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10249 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10250 execute(info);
10251 bool fail = info.isUnwalkable();
10252
10253 if(!fail) //not solid, but check for water/pits...
10254 {
10255 if(onWater(true))
10256 fail = true;
10257 if(pitslide() || fallclk)
10258 fail = true;
10259 fallclk = 0;
10260 }
10261 x = tx; y = ty; z = tz;
10262 return fail;
10263 }
10264
10265 void HeroClass::doMirror(int32_t mirrorid)
10266 {
10267 if(z > 0 || fakez > 0) return; //No mirror in air
10268 if(mirrorid < 0)
10269 mirrorid = current_item_id(itype_mirror);
10270 if(mirrorid < 0) return;
10271
10272 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10273 {
10274 item_error();
10275 return;
10276 }
10277 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10278 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10279 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10280 for(auto pos : posarr)
10281 {
10282 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10283 {
10284 item_error();
10285 return;
10286 }
10287 }
10288
10289 itemdata const& mirror = itemsbuf[mirrorid];
10290 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10291 {
10292 paymagiccost(mirrorid);
10293 if(mirror.usesound2) sfx(mirror.usesound2);
10294
10295 doWarpEffect(mirror.misc2, true);
10296 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10297 {
10298 Quit = qCONT;
10299 skipcont = 1;
10300 }
10301 else //Act as Divine Escape
10302 {
10303 int32_t div_prot_temp=div_prot_item;
10304 restart_level();
10305 div_prot_item=div_prot_temp;
10306 magicitem=-1;
10307 magiccastclk=0;
10308 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10309 }
10310 }
10311 else
10312 {
10313 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10314 int32_t offscr = currscr - DMaps[currdmap].xoff;
10315 if(destdmap < 0)
10316 return;
10317 int32_t destscr = DMaps[destdmap].xoff + offscr;
10318 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10319 return;
10320 paymagiccost(mirrorid);
10321
10322 //Store some values to restore if 'warp fails'
10323 int32_t tLastEntrance = lastentrance,
10324 tLastEntranceDMap = lastentrance_dmap,
10325 tContScr = game->get_continue_scrn(),
10326 tContDMap = game->get_continue_dmap(),
10327 tPortalDMap = game->saved_mirror_portal.srcdmap;
10328 int32_t sourcescr = currscr, sourcedmap = currdmap;
10329 zfix tx = x, ty = y, tz = z;
10330 game->saved_mirror_portal.srcdmap = -1;
10331 action = none; FFCore.setHeroAction(none);
10332
10333 //Warp to new dmap
10334 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10335 mirror.usesound, 0, -1);
10336
10337 //Check for valid landing location
10338 if(mirrorBonk()) //Invalid landing, warp back!
10339 {
10340 action = none; FFCore.setHeroAction(none);
10341 lastentrance = tLastEntrance;
10342 lastentrance_dmap = tLastEntranceDMap;
10343 game->set_continue_scrn(tContScr);
10344 game->set_continue_dmap(tContDMap);
10345 x = tx;
10346 y = ty;
10347 z = tz;
10348 game->saved_mirror_portal.srcdmap = tPortalDMap;
10349 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10350 mirror.usesound, 0, -1);
10351 }
10352 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10353 {
10354 //Place the portal
10355 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10356 //Since it was placed after loading this screen, load the portal object now
10357 game->load_portal();
10358 //Don't immediately trigger the warp back
10359 mirror_portal.prox_active = false;
10360
10361 //Set continue point
10362 if(currdmap != game->get_continue_dmap())
10363 {
10364 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10365 }
10366 game->set_continue_dmap(currdmap);
10367 lastentrance_dmap = currdmap;
10368 lastentrance = game->get_continue_scrn();
10369 }
10370 }
10371 }
10372
10373 7262487 void HeroClass::handle_passive_buttons()
10374 {
10375 7262487 do_liftglove(-1,true);
10376 7262487 do_jump(-1,true);
10377 7262487 }
10378
10379 static bool did_passive_jump = false;
10380 7262513 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10381 {
10382
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7262487 times.
7262513 if(passive) did_passive_jump = false;
10383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 else if(did_passive_jump) return false; //don't jump twice in the same frame
10384
10385
2/2
✓ Branch 0 taken 300763 times.
✓ Branch 1 taken 6961750 times.
7262513 if(nomove_action(action)) return false; //can't jump while ex. drowning
10386
2/2
✓ Branch 0 taken 52619 times.
✓ Branch 1 taken 6909131 times.
6961750 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10387
10388
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6909105 times.
6909131 if(jumpid < 0)
10389 6909105 jumpid = current_item_id(itype_rocs,true,true);
10390
10391
2/2
✓ Branch 0 taken 6730953 times.
✓ Branch 1 taken 178178 times.
6909131 if(unsigned(jumpid) >= MAXITEMS) return false;
10392
4/4
✓ Branch 0 taken 178067 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 176656 times.
178178 if(inlikelike || charging) return false;
10393
1/2
✓ Branch 0 taken 176656 times.
✗ Branch 1 not taken.
176656 if(!checkitem_jinx(jumpid)) return false;
10394
10395 176656 itemdata const& itm = itemsbuf[jumpid];
10396
10397 176656 bool standing = isStanding(true);
10398
3/4
✓ Branch 0 taken 175691 times.
✓ Branch 1 taken 965 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 965 times.
176656 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10399
4/6
✓ Branch 0 taken 176656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 175691 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 965 times.
176656 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10400
3/4
✓ Branch 0 taken 173889 times.
✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173889 times.
175691 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10401 {
10402 1802 item_error();
10403 1802 return false;
10404 }
10405
10406 173889 byte intbtn = byte(itm.misc2&0xFF);
10407
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 173866 times.
173889 if(passive)
10408 {
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 173866 times.
173866 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10410 173866 return false; //not pressed
10411 }
10412
10413 23 paymagiccost(jumpid);
10414
10415
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!standing)
10416 {
10417 ++extra_jump_count;
10418 fall = 0;
10419 fakefall = 0;
10420 if(hoverclk > 0)
10421 hoverclk = -hoverclk;
10422 }
10423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(itm.flags & ITEM_FLAG1)
10424 setFall(fall - itm.power);
10425 23 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10426 23 coyotetime = 65535; //jumped, so no coyotetime
10427 23 setOnSideviewLadder(false);
10428
10429 // Reset the ladder, unless on an unwalkable combo
10430
3/10
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 23 times.
✗ Branch 9 not taken.
23 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10431 reset_ladder();
10432
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(itm.usesound)
10434 23 sfx(itm.usesound,pan(x.getInt()));
10435
10436
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(passive)
10437 {
10438 did_passive_jump = true;
10439 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10440 }
10441 23 return true;
10442 7262513 }
10443 1147 void HeroClass::drop_liftwpn()
10444 {
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
1147 if(!lift_wpn) return;
10446
10447 handle_lift(false); //sets position properly, accounting for large weapons
10448 auto liftid = current_item_id(itype_liftglove,true,true);
10449 itemdata const& glove = itemsbuf[liftid];
10450 if(isSideViewGravity())
10451 {
10452 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10453 }
10454 else
10455 {
10456 auto lheight = liftheight+z+fakez;
10457 if(glove.flags & ITEM_FLAG1)
10458 {
10459 lift_wpn->z = 0;
10460 lift_wpn->fakez = lheight;
10461 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10462 }
10463 else
10464 {
10465 lift_wpn->z = lheight;
10466 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10467 }
10468 }
10469 lift_wpn->dir = dir;
10470 lift_wpn->step = 0;
10471 lift_wpn->fakefall = 0;
10472 lift_wpn->fall = 0;
10473 Lwpns.add(lift_wpn);
10474 lift_wpn = nullptr;
10475 1147 }
10476 7262487 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10477 {
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262487 times.
7262487 if(liftid < 0)
10479 7262487 liftid = current_item_id(itype_liftglove,true,true);
10480
2/2
✓ Branch 0 taken 11290 times.
✓ Branch 1 taken 7251197 times.
7262487 if(!can_lift(liftid)) return;
10481 11290 itemdata const& glove = itemsbuf[liftid];
10482 11290 byte intbtn = byte(glove.misc1&0xFF);
10483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11290 times.
11290 if(passive)
10484 {
10485
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 11218 times.
11290 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10486 11218 return; //not pressed
10487 72 }
10488
10489 72 bool had_weapon = lift_wpn;
10490
10491
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
125 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10492
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 2 times.
55 (checkbunny(liftid) && checkmagiccost(liftid))))
10493 {
10494 2 item_error();
10495 2 return;
10496 }
10497
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
70 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
10498 return;
10499
10500 70 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10501
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
70 if(glove.script)
10502 {
10503 if(!paidmagic)
10504 {
10505 paidmagic = true;
10506 paymagiccost(liftid);
10507 }
10508
10509 int i = liftid;
10510 FFCore.reset_script_engine_data(ScriptType::Item, i);
10511 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
10512 FFCore.deallocateAllArrays(ScriptType::Item,i);
10513
10514 bool has_weapon = lift_wpn;
10515 if(has_weapon != had_weapon) //Item action script changed the lift information
10516 {
10517 if(passive)
10518 {
10519 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10520 }
10521 return;
10522 }
10523 }
10524
10525
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 53 times.
70 if(lift_wpn)
10526 {
10527
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!paidmagic)
10528 {
10529 paidmagic = true;
10530 paymagiccost(liftid);
10531 }
10532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!liftclk)
10533 {
10534 //Throw the weapon!
10535 //hero's direction and position
10536 17 handle_lift(false); //sets position properly, accounting for large weapons
10537
10538 17 lift_wpn->dir = dir;
10539 //Configured throw speed in both axes
10540 17 auto basestep = glove.misc2;
10541 17 lift_wpn->step = zfix(basestep)/100;
10542
10543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(isSideViewGravity())
10544 {
10545 lift_wpn->fall = -glove.misc3;
10546 switch(dir)
10547 {
10548 case left: case right:
10549 break; //nothing special for sideways
10550 case up: //step converts to upwards fall
10551 lift_wpn->fall -= basestep;
10552 lift_wpn->step = 0;
10553 break;
10554 case down: //step converts into straight down fall
10555 lift_wpn->fall = zc_min(basestep,zinit.terminalv);
10556 lift_wpn->step = 0;
10557 break;
10558 }
10559 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10560 }
10561 else
10562 {
10563 17 auto lheight = liftheight+z+fakez;
10564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(glove.flags & ITEM_FLAG1)
10565 {
10566 lift_wpn->z = 0;
10567 lift_wpn->fakez = lheight;
10568 lift_wpn->fakefall = -glove.misc3;
10569 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10570 }
10571 else
10572 {
10573 17 lift_wpn->z = lheight;
10574 17 lift_wpn->fall = -glove.misc3;
10575 17 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10576 }
10577 }
10578 17 Lwpns.add(lift_wpn);
10579 17 lift_wpn = nullptr;
10580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(glove.usesound2)
10581 17 sfx(glove.usesound2,pan(int32_t(x)));
10582 17 }
10583
10584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(passive)
10585 {
10586 17 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10587 17 }
10588 17 return;
10589 }
10590
10591 53 bool lifted = false;
10592 //Check for a liftable weapon
10593 //if(!lifted)
10594 {
10595 53 zfix hx, hy, hw, hh;
10596
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 17 times.
53 switch(dir)
10597 {
10598 case up:
10599 18 hx = x;
10600 18 hy = y-8;
10601 18 hw = 16;
10602 18 hh = bigHitbox ? 8 : 16;
10603 18 break;
10604 case down:
10605 9 hx = x;
10606 9 hy = y+16;
10607 9 hw = 16;
10608 9 hh = 8;
10609 9 break;
10610 case left:
10611 9 hx = x-8;
10612 9 hy = y;
10613 9 hw = 8;
10614 9 hh = 16;
10615 9 break;
10616 case right:
10617 17 hx = x+16;
10618 17 hy = y;
10619 17 hw = 8;
10620 17 hh = 16;
10621 17 break;
10622 }
10623
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 20 times.
73 for(int32_t q = 0; q < Lwpns.Count(); ++q)
10624 {
10625 20 weapon* w = (weapon*)Lwpns.spr(q);
10626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 if((w->lift_level && w->lift_level <= glove.fam_type))
10627 {
10628 if(!w->hit(hx,hy,0,hw,hh,1))
10629 continue;
10630 lift(w, w->lift_time, w->lift_height);
10631 Lwpns.remove(w);
10632 lifted = true;
10633 break;
10634 }
10635 20 }
10636 }
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(!lifted) //Check for a liftable combo
10638 {
10639 53 zfix bx, by;
10640 53 zfix bx2, by2;
10641
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 17 times.
53 switch(dir)
10642 {
10643 case up:
10644 18 by = y + (bigHitbox ? -2 : 6);
10645 18 by2 = by;
10646 18 bx = x + 4;
10647 18 bx2 = bx + 8;
10648 18 break;
10649 case down:
10650 9 by = y + 17;
10651 9 by2 = by;
10652 9 bx = x + 4;
10653 9 bx2 = bx + 8;
10654 9 break;
10655 case left:
10656 9 by = y + (bigHitbox ? 0 : 8);
10657 9 by2 = y + 8;
10658 9 bx = x - 2;
10659 9 bx2 = x - 2;
10660 9 break;
10661 case right:
10662 17 by = y + (bigHitbox ? 0 : 8);
10663 17 by2 = y + 8;
10664 17 bx = x + 17;
10665 17 bx2 = x + 17;
10666 17 break;
10667 }
10668 53 int32_t pos = COMBOPOS_B(bx,by);
10669 53 int32_t pos2 = COMBOPOS_B(bx2,by2);
10670 53 int32_t foundpos = -1;
10671
10672
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 367 times.
403 for(auto lyr = 6; lyr >= 0; --lyr)
10673 {
10674 367 mapscr* scr = FFCore.tempScreens[lyr];
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(pos > -1)
10676 {
10677 367 newcombo const& cmb = combobuf[scr->data[pos]];
10678
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 17 times.
367 if(cmb.liftflags & LF_LIFTABLE)
10679 {
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(do_lift_combo(lyr,pos,liftid))
10681 {
10682 17 lifted = true;
10683 17 break;
10684 }
10685 }
10686 350 }
10687
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 252 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
350 if(pos != pos2 && pos2 > -1)
10688 {
10689 98 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10690
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(cmb2.liftflags & LF_LIFTABLE)
10691 {
10692 if(do_lift_combo(lyr,pos2,liftid))
10693 {
10694 lifted = true;
10695 break;
10696 }
10697 }
10698 98 }
10699 350 }
10700 53 }
10701
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 36 times.
53 if(!lifted) return;
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!paidmagic)
10703 {
10704 17 paidmagic = true;
10705 17 paymagiccost(liftid);
10706 17 }
10707 17 set_liftflags(liftid);
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(passive)
10709 17 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10710 17 return;
10711 7262487 }
10712 2375 void HeroClass::handle_lift(bool dec)
10713 {
10714
1/2
✓ Branch 0 taken 2375 times.
✗ Branch 1 not taken.
2375 if(lift_wpn)
10715 2375 lift_wpn->fakez = 0;
10716 else liftclk = 0;
10717
2/2
✓ Branch 0 taken 1977 times.
✓ Branch 1 taken 398 times.
2375 if(liftclk <= (dec?1:0))
10718 {
10719 1977 liftclk = 0;
10720 1977 tliftclk = 0;
10721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(lift_wpn)
10722 {
10723
2/4
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1977 times.
1977 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10724 {
10725 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10726 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10727 }
10728 else
10729 {
10730 1977 lift_wpn->x = x;
10731 1977 lift_wpn->y = y;
10732 }
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(isSideViewGravity())
10734 lift_wpn->y -= liftheight;
10735 1977 else lift_wpn->z = liftheight;
10736 1977 }
10737
2/2
✓ Branch 0 taken 1960 times.
✓ Branch 1 taken 17 times.
1977 if(action == lifting)
10738 {
10739 17 action = none; FFCore.setHeroAction(none);
10740 17 }
10741 1977 return;
10742 }
10743
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 199 times.
398 if(dec) --liftclk;
10744 double xdist, ydist;
10745 398 double perc = (liftclk/double(tliftclk));
10746
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 130 times.
398 switch(dir)
10747 {
10748 case up:
10749 {
10750 44 xdist = 0;
10751 44 ydist = -16;
10752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(lift_wpn->txsz > 1)
10753 {
10754 xdist = -((lift_wpn->txsz*8)-8);
10755 }
10756 44 else xdist = 0;
10757
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(lift_wpn->tysz > 1)
10758 {
10759 ydist = -(lift_wpn->tysz*16);
10760 }
10761 44 ydist *= perc;
10762 44 break;
10763 }
10764 case down:
10765 {
10766 104 xdist = 0;
10767 104 ydist = 16;
10768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(lift_wpn->txsz > 1)
10769 {
10770 xdist = -((lift_wpn->txsz*8)-8);
10771 }
10772 104 else xdist = 0;
10773 104 ydist *= perc;
10774 104 break;
10775 }
10776 case left:
10777 {
10778 120 xdist = -16;
10779 120 ydist = 0;
10780
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(lift_wpn->txsz > 1)
10781 {
10782 xdist = -(lift_wpn->txsz*16);
10783 }
10784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 if(lift_wpn->tysz > 1)
10785 {
10786 ydist = -((lift_wpn->tysz*8)-8);
10787 }
10788 120 else ydist = 0;
10789 120 xdist *= perc;
10790 120 break;
10791 }
10792 case right:
10793 {
10794 130 xdist = 16;
10795 130 ydist = 0;
10796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if(lift_wpn->tysz > 1)
10797 {
10798 ydist = -((lift_wpn->tysz*8)-8);
10799 }
10800 130 else ydist = 0;
10801 130 xdist *= perc;
10802 130 break;
10803 }
10804 }
10805
10806 398 lift_wpn->x = x + xdist;
10807 398 lift_wpn->y = y + ydist;
10808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if(isSideViewGravity())
10809 lift_wpn->y -= liftheight*(1.0-perc);
10810 398 else lift_wpn->z = liftheight*(1.0-perc);
10811 2375 }
10812 7262504 bool HeroClass::can_lift(int32_t gloveid)
10813 {
10814
2/2
✓ Branch 0 taken 7249865 times.
✓ Branch 1 taken 12639 times.
7262504 if(unsigned(gloveid) >= MAXITEMS) return false;
10815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12639 times.
12639 if(lstunclock) return false;
10816
1/2
✓ Branch 0 taken 12639 times.
✗ Branch 1 not taken.
12639 if(!checkitem_jinx(gloveid)) return false;
10817 12639 itemdata const& glove = itemsbuf[gloveid];
10818
2/3
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 11307 times.
✗ Branch 2 not taken.
12639 switch(action)
10819 {
10820 case none: case walking:
10821 11307 break;
10822
10823 case swimming:
10824 if(glove.flags & ITEM_FLAG2)
10825 break;
10826 return false;
10827
10828 default:
10829 1332 return false;
10830 }
10831 11307 return true;
10832 7262504 }
10833 17 void HeroClass::lift(weapon* w, byte timer, zfix height)
10834 {
10835 17 lift_wpn = w;
10836 17 liftclk = timer;
10837 17 tliftclk = timer;
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(height < 0)
10839 liftheight = 0;
10840 17 else liftheight = height;
10841 17 }
10842
10843 1 void HeroClass::doSwitchHook(byte style)
10844 {
10845 1 hs_switcher = true;
10846 1 pull_hero = true;
10847 //{ Load hook weapons, set them to obey special drawing
10848 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10849 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10850
10851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w)
10852 1 w->switch_hooked = true;
10853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hw)
10854 1 hw->switch_hooked = true;
10855
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
10856 {
10857 5 chainlinks.spr(j)->switch_hooked = true;
10858 5 }
10859 //}
10860
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1)
10861 {
10862 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10863 hooked_layerbits = 0;
10864 for(auto q = 0; q < 7; ++q)
10865 hooked_undercombos[q] = -1;
10866 uint16_t plpos = COMBOPOS(x+8,y+8);
10867 for(auto q = max_layer; q > -1; --q)
10868 {
10869 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10870 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10871 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10872 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10873 bool isPush = false;
10874 if(isSwitchHookable(cmb))
10875 {
10876 if(cmb.type == cSWITCHHOOK)
10877 {
10878 uint16_t plpos = COMBOPOS(x+8,y+8);
10879 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10880 continue; //don't swap with non-zero combo
10881 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10882 continue; //too low a switchhook level
10883 hooked_layerbits |= 1<<q; //Swapping
10884 if(cmb.usrflags&cflag3)
10885 {
10886 if(cmb.usrflags&cflag6)
10887 {
10888 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10889 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10890 }
10891 else
10892 {
10893 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10894 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10895 }
10896 }
10897 else
10898 {
10899 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10900 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10901 isPush = true;
10902 }
10903 }
10904 else if(isCuttableType(cmb.type))
10905 {
10906 if(isCuttableNextType(cmb.type))
10907 {
10908 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10909 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10910 }
10911 else
10912 {
10913 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10914 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10915 }
10916 hooked_layerbits |= 1<<q; //Swapping
10917 }
10918 else
10919 {
10920 hooked_layerbits |= 1<<q; //Swapping
10921 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10922 }
10923 }
10924 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10925 {
10926 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10927 && hasMainGuy())
10928 {
10929 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10930 continue;
10931 }
10932 if(fl1 == mfPUSHED)
10933 {
10934 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10935 continue;
10936 }
10937 if(!isPush) switch(fl1)
10938 {
10939 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10940 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10941 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10942 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10943 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10944 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10945 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10946 isPush = true;
10947 }
10948 if(!isPush) switch(cmb.flag)
10949 {
10950 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10951 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10952 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10953 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10954 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10955 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10956 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10957 isPush = true;
10958 }
10959 if(isPush) //Check for block holes / triggers
10960 {
10961 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10962 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10963 {
10964 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10965 }
10966 else if(!get_qr(qr_BLOCKHOLE_SAME_ONLY))
10967 {
10968 auto maxLayer = get_qr(qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10969 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10970 {
10971 if(lyr == q) continue;
10972 switch(FFCore.tempScreens[q]->sflag[plpos])
10973 {
10974 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10975 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10976 lyr=7;
10977 break;
10978 }
10979 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10980 {
10981 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10982 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10983 lyr=7;
10984 break;
10985 }
10986 }
10987 }
10988 }
10989 }
10990 }
10991 }
10992 1 switch_hooked = true;
10993 1 switchhookstyle = style;
10994
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(style)
10995 {
10996 default: case swPOOF:
10997 {
10998 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10999
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
11000
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
11002 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
11004
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11005 1 break;
11006 }
11007 case swFLICKER:
11008 {
11009 switchhookmaxtime = switchhookclk = 64;
11010 break;
11011 }
11012 case swRISE:
11013 {
11014 switchhookmaxtime = switchhookclk = 64;
11015 break;
11016 }
11017 }
11018 1 }
11019
11020 30910 bool HeroClass::startwpn(int32_t itemid)
11021 {
11022
2/2
✓ Branch 0 taken 29246 times.
✓ Branch 1 taken 1664 times.
30910 if(itemid < 0) return false;
11023 29246 itemdata const& itm = itemsbuf[itemid];
11024
5/6
✓ Branch 0 taken 7122 times.
✓ Branch 1 taken 22124 times.
✓ Branch 2 taken 5586 times.
✓ Branch 3 taken 16538 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
29298 if(((dir==up && y<24) || (dir==down && y>128) ||
11025
6/6
✓ Branch 0 taken 8102 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 8434 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 29192 times.
29246 (dir==left && x<32) || (dir==right && x>208)) && !(get_qr(qr_ITEMSONEDGES) || inlikelike))
11026 52 return false;
11027
11028
1/2
✓ Branch 0 taken 29194 times.
✗ Branch 1 not taken.
29194 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
11029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29194 times.
29194 if(liftonly)
11030 {
11031 dowpn = -1;
11032 switch(itm.family)
11033 {
11034 case itype_bomb:
11035 case itype_sbomb:
11036 if(itm.flags & ITEM_FLAG4)
11037 do_liftglove(-1,false);
11038 break;
11039 case itype_liftglove:
11040 do_liftglove(-1,false);
11041 break;
11042 }
11043 return false;
11044 }
11045
11046 29194 int32_t wx=x;
11047 29194 int32_t wy=y-fakez;
11048 29194 int32_t wz=z;
11049 29194 bool ret = true;
11050
11051
5/5
✓ Branch 0 taken 8426 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7109 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 8083 times.
29194 switch(dir)
11052 {
11053 case up:
11054 7109 wy-=16;
11055 7109 break;
11056
11057 case down:
11058 5574 wy+=16;
11059 5574 break;
11060
11061 case left:
11062 8083 wx-=16;
11063 8083 break;
11064
11065 case right:
11066 8426 wx+=16;
11067 8426 break;
11068 }
11069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29194 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
11070
11071
15/27
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 1163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 26 times.
✓ Branch 9 taken 4 times.
✓ Branch 10 taken 183 times.
✓ Branch 11 taken 756 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 1535 times.
✓ Branch 14 taken 13312 times.
✓ Branch 15 taken 1120 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 950 times.
✓ Branch 18 taken 11 times.
✓ Branch 19 taken 9864 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
29194 switch(itm.family)
11072 {
11073 case itype_liftglove:
11074 {
11075 do_liftglove(itemid,false);
11076 dowpn = -1;
11077 ret = false;
11078 break;
11079 }
11080 case itype_potion:
11081 {
11082
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11083 {
11084 return item_error();
11085 }
11086
11087 23 paymagiccost(itemid);
11088
11089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(itm.misc1 || itm.misc2)
11090 {
11091 23 refill_what=REFILL_ALL;
11092 23 refill_why=itemid;
11093 23 StartRefill(REFILL_ALL);
11094 23 potion_life = game->get_life();
11095 23 potion_magic = game->get_magic();
11096
11097 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11098 //music_pause();
11099 23 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11100
2/2
✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 23 times.
4955 while(refill())
11101 {
11102 4932 do_refill_waitframe();
11103 }
11104
11105 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11106 //music_resume();
11107 23 ret = false;
11108 23 }
11109
11110 23 break;
11111 }
11112 case itype_bottle:
11113 {
11114 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11115 {
11116 return item_error();
11117 }
11118 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11119 return false;
11120
11121 size_t bind = game->get_bottle_slot(itm.misc1);
11122 bool paidmagic = false;
11123 if(itm.script)
11124 {
11125 paidmagic = true;
11126 paymagiccost(itemid);
11127
11128 int i = itemid;
11129 FFCore.reset_script_engine_data(ScriptType::Item, i);
11130 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11131 bind = game->get_bottle_slot(itm.misc1);
11132 }
11133 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11134 if(bt)
11135 {
11136 word toFill[3] = { 0 };
11137 for(size_t q = 0; q < 3; ++q)
11138 {
11139 char c = bt->counter[q];
11140 if(c > -1)
11141 {
11142 if(bt->flags & (1<<q))
11143 {
11144 toFill[q] = (bt->amount[q]==100)
11145 ? game->get_maxcounter(c)
11146 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11147 }
11148 else toFill[q] = bt->amount[q];
11149 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11150 {
11151 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11152 }
11153 }
11154 }
11155 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11156 bool run = max > 0;
11157 if(get_qr(qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11158 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
11159 else
11160 {
11161 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11162 run = true;
11163 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11164 run = true;
11165 }
11166 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11167 {
11168 if(bt->flags & BTFLAG_CURESWJINX)
11169 {
11170 swordclk = 0;
11171 verifyAWpn();
11172 }
11173 if(bt->flags & BTFLAG_CUREITJINX)
11174 itemclk = 0;
11175 if(!paidmagic)
11176 paymagiccost(itemid);
11177 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11178 sfx(itm.usesound,pan(x.getInt()));
11179 for(size_t q = 0; q < 20; ++q)
11180 do_refill_waitframe();
11181 double inc = max/60.0; //1 second
11182 double xtra[3]{ 0 };
11183 for(size_t q = 0; q < 60; ++q)
11184 {
11185 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11186 sfx(QMisc.miscsfx[sfxREFILL]);
11187 for(size_t j = 0; j < 3; ++j)
11188 {
11189 xtra[j] += inc;
11190 word f = floor(xtra[j]);
11191 xtra[j] -= f;
11192 if(toFill[j] > f)
11193 {
11194 toFill[j] -= f;
11195 game->change_counter(f,bt->counter[j]);
11196 }
11197 else if(toFill[j])
11198 {
11199 game->change_counter(toFill[j],bt->counter[j]);
11200 toFill[j] = 0;
11201 }
11202 }
11203 do_refill_waitframe();
11204 }
11205 for(size_t j = 0; j < 3; ++j)
11206 {
11207 if(toFill[j])
11208 {
11209 game->change_counter(toFill[j],bt->counter[j]);
11210 toFill[j] = 0;
11211 }
11212 }
11213 for(size_t q = 0; q < 20; ++q)
11214 do_refill_waitframe();
11215 game->set_bottle_slot(itm.misc1, bt->next_type);
11216 }
11217 }
11218
11219 dowpn = -1;
11220 ret = false;
11221 break;
11222 }
11223
11224 case itype_note:
11225 {
11226 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11227 {
11228 return item_error();
11229 }
11230 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11231 {
11232 sfx(itm.usesound);
11233 donewmsg(itm.misc1);
11234 paymagiccost(itemid);
11235 }
11236 dowpn = -1;
11237 ret = false;
11238 break;
11239 }
11240
11241 case itype_mirror:
11242 doMirror(itemid);
11243 if(Quit)
11244 return false;
11245 ret = false;
11246 break;
11247
11248 case itype_rocs:
11249 {
11250
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 3 times.
26 if(!do_jump(itemid,false)) return false;
11251 23 ret = false;
11252 }
11253 23 break;
11254
11255 case itype_letter:
11256 {
11257
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 if(current_item(itype_letter)==i_letter &&
11258
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11259
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tmpscr[currscr<128?0:1].guy &&
11260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11261
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11262 4 checkbunny(itemid)
11263 )
11264 {
11265 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11266
11267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11268 4 getitem(usedid, true, true);
11269
11270 4 sfx(tmpscr[currscr<128?0:1].secretsfx);
11271 4 setupscreen();
11272 4 action=none; FFCore.setHeroAction(none);
11273 4 }
11274
11275 4 ret = false;
11276 }
11277 4 break;
11278
11279 case itype_whistle:
11280 {
11281 bool whistleflag;
11282
11283
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 179 times.
183 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11284 {
11285 4 return item_error();
11286 }
11287
11288 179 paymagiccost(itemid);
11289 179 sfx(itm.usesound);
11290
11291
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 78 times.
179 if(dir==up || dir==right)
11292 101 ++blowcnt;
11293 else
11294 78 --blowcnt;
11295
11296 179 int sfx_count = 0;
11297
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32759 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32761 times.
✓ Branch 6 taken 32580 times.
✓ Branch 7 taken 183 times.
32759 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11298 {
11299 32580 sfx_count += 1;
11300 32580 advanceframe(true);
11301
11302
1/2
✓ Branch 0 taken 32580 times.
✗ Branch 1 not taken.
32580 if(Quit)
11303 return false;
11304 }
11305
11306
9/14
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 181 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 181 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 181 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 181 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 181 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 183 times.
✓ Branch 13 taken 2 times.
183 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11307
11308
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 17 times.
183 if((whistleflag=findentrance(x,y,mfWHISTLE,get_qr(qr_PERMANENT_WHISTLE_SECRETS))))
11309 17 didstuff |= did_whistle;
11310
11311
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 164 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 164 times.
183 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11312 19 return false;
11313
11314
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 162 times.
164 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11315
11316
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 136 times.
164 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11317
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 || (tmpscr->flags7&fWHISTLEPAL))
11318 {
11319 32 whistleclk=0; // signal to start drying lake or doing other stuff
11320 32 }
11321 else
11322 {
11323 136 int32_t where = itm.misc1;
11324
11325
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(where>right) where=dir^1;
11326
11327
5/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
225 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11328
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
93 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11329
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 89 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 89 times.
✗ Branch 11 not taken.
178 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11330
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 89 times.
✗ Branch 9 not taken.
89 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11331
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 (zfix)0,
11332 wWind,
11333 0, //type
11334 0,
11335 89 where,
11336
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11337
11338 132 whistleitem=itemid;
11339 }
11340
11341 162 ret = false;
11342 }
11343 162 break;
11344
11345 case itype_bomb:
11346 {
11347 //Remote detonation
11348
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 751 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 755 times.
756 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11349 {
11350 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11351
11352
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11353 {
11354 //If this ever needs a version check, in the future. -z
11355 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11356 {
11357 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11358 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11359 }
11360 ew->misc=50;
11361 ew->clk=ew->misc-3;
11362 ew->id=wBomb;
11363 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11364 }
11365
11366 1 deselectbombs(false);
11367 1 return false;
11368 }
11369
11370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
755 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11371 {
11372 do_liftglove(-1,false); //Throw the already-held weapon
11373 return false;
11374 }
11375
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 755 times.
755 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11376 {
11377 return item_error();
11378 }
11379
11380 755 paymagiccost(itemid);
11381
11382
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(itm.misc1>0) // If not remote bombs
11383 755 deselectbombs(false);
11384
11385
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 583 times.
755 if(isdungeon())
11386 {
11387
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 63 times.
583 wy=zc_max(wy,16);
11388 583 }
11389
11390
4/8
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 755 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 755 times.
✗ Branch 7 not taken.
1510 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11391
2/4
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 755 times.
✗ Branch 3 not taken.
755 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
11392 755 bool lifted = false;
11393
1/2
✓ Branch 0 taken 755 times.
✗ Branch 1 not taken.
755 if(itm.flags & ITEM_FLAG4)
11394 {
11395 auto liftid = current_item_id(itype_liftglove);
11396 itemdata const& glove = itemsbuf[liftid];
11397 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11398 {
11399 lift(wpn,itm.misc5,itm.misc6);
11400 set_liftflags(liftid);
11401 lifted = true;
11402 }
11403 }
11404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 755 times.
755 if(!lifted)
11405 {
11406 755 Lwpns.add(wpn);
11407 755 sfx(WAV_PLACE,pan(wx));
11408 755 }
11409 }
11410 755 break;
11411
11412 case itype_sbomb:
11413 {
11414 //Remote detonation
11415
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11416 {
11417 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11418
11419 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11420 {
11421 ew->misc=50;
11422 ew->clk=ew->misc-3;
11423 ew->id=wSBomb;
11424 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11425 }
11426
11427 deselectbombs(true);
11428 return false;
11429 }
11430
11431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if((itm.flags & ITEM_FLAG4) && lift_wpn)
11432 {
11433 do_liftglove(-1,false); //Throw the already-held weapon
11434 return false;
11435 }
11436
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11437 {
11438 return item_error();
11439 }
11440
11441 18 paymagiccost(itemid);
11442
11443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(itm.misc1>0) // If not remote bombs
11444 18 deselectbombs(true);
11445
11446
6/12
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
18 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true);
11447 18 bool lifted = false;
11448
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(itm.flags & ITEM_FLAG4)
11449 {
11450 auto liftid = current_item_id(itype_liftglove);
11451 itemdata const& glove = itemsbuf[liftid];
11452 if(liftid > -1 && (!itm.misc4 || itm.misc4 <= glove.fam_type))
11453 {
11454 lift(wpn,itm.misc5,itm.misc6);
11455 set_liftflags(liftid);
11456 lifted = true;
11457 }
11458 }
11459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!lifted)
11460 {
11461 18 Lwpns.add(wpn);
11462 18 sfx(WAV_PLACE,pan(wx));
11463 18 }
11464 }
11465 18 break;
11466
11467 case itype_wand:
11468 {
11469
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 1096 times.
1535 if(Lwpns.idCount(wMagic))
11470 {
11471 439 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11472 439 return false;
11473 }
11474
11475 1096 int32_t bookid = current_item_id(itype_book);
11476
3/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 653 times.
1096 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11477
11478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1096 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11479 {
11480 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11481 return false;
11482 }
11483
11484
4/6
✓ Branch 0 taken 1096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1096 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1 times.
1096 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11485 {
11486 1 return item_error();
11487 }
11488
11489
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 3 times.
1095 if(Lwpns.idCount(wBeam))
11490 3 Lwpns.del(Lwpns.idFirst(wBeam));
11491
11492 int32_t type, pow;
11493
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 666 times.
1095 if ( get_qr(qr_BROKENBOOKCOST) )
11494 {
11495
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 350 times.
429 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11496
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 350 times.
429 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11497 429 }
11498 else
11499 {
11500
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11501
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11502 }
11503
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2190 times.
✓ Branch 4 taken 1095 times.
✓ Branch 5 taken 1095 times.
2190 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
2190 if(dir!=(i^1))
11505 {
11506
5/10
✓ Branch 0 taken 1095 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1095 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1095 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1095 times.
✗ Branch 9 not taken.
1095 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11507
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11508 653 magic->linkedItem = bookid;
11509 //magic->dir = this->dir; //Save player dir for special weapons.
11510 1095 Lwpns.add(magic);
11511 1095 }
11512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1095 times.
1095 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11513 1095 paymagiccost(itemid);
11514 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11515
11516
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 653 times.
1095 if(paybook)
11517 653 paymagiccost(current_item_id(itype_book));
11518
11519
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 442 times.
1095 if(bookid != -1)
11520 {
11521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 653 times.
653 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11522 {
11523 sfx(itemsbuf[bookid].misc2,pan(wx));
11524 }
11525 else
11526 {
11527 653 sfx(itm.usesound,pan(wx));
11528 }
11529 653 }
11530 else
11531 442 sfx(itm.usesound,pan(wx));
11532 }
11533 /*
11534 // Fireball Wand
11535 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11536 switch (dir)
11537 {
11538 case up:
11539 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11540 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11541 break;
11542 case down:
11543 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11544 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11545 break;
11546 case left:
11547 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11548 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11549 break;
11550 case right:
11551 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11552 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11553 break;
11554 }
11555 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11556 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11557 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11558 */
11559 1095 break;
11560
11561 case itype_sword:
11562 {
11563
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13312 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11564 {
11565 return item_error();
11566 }
11567
11568
4/4
✓ Branch 0 taken 2619 times.
✓ Branch 1 taken 10693 times.
✓ Branch 2 taken 2619 times.
✓ Branch 3 taken 10693 times.
13312 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11569 {
11570 2619 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11571 2619 return false;
11572 }
11573
11574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10693 times.
10693 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11575 10693 paymagiccost(itemid);
11576 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11577 float temppower;
11578
11579
1/2
✓ Branch 0 taken 10693 times.
✗ Branch 1 not taken.
10693 if(itm.flags & ITEM_FLAG2)
11580 {
11581 10693 temppower=game->get_hero_dmgmult()*itm.power;
11582 10693 temppower=temppower*itm.misc2;
11583 10693 temppower=temppower/100;
11584 10693 }
11585 else
11586 {
11587 temppower = game->get_hero_dmgmult()*itm.misc2;
11588 }
11589
11590 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11591 //Add weapon script to sword beams.
11592
5/10
✓ Branch 0 taken 10693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10693 times.
✗ Branch 9 not taken.
10693 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11593 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11594 //w->weaponscript = itm.weaponscript;
11595 //w->canrunscript = 0;
11596 10693 sfx(WAV_BEAM,pan(wx));
11597 }
11598 10693 break;
11599
11600 case itype_candle:
11601 {
11602 1120 int32_t countid = itemid;
11603
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1092 times.
1120 if(get_qr(qr_CANDLES_SHARED_LIMIT))
11604 1092 countid = -itype_candle;
11605
5/6
✓ Branch 0 taken 817 times.
✓ Branch 1 taken 303 times.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 1104 times.
1120 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11606 {
11607 16 return false;
11608 }
11609
11610
3/4
✓ Branch 0 taken 1104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 1041 times.
1104 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
11611 {
11612 63 return false;
11613 }
11614
11615
3/4
✓ Branch 0 taken 1041 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1033 times.
1041 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11616 {
11617 8 return item_error();
11618 }
11619
11620 1033 paymagiccost(itemid);
11621
11622
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 279 times.
1033 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11623
11624
4/8
✓ Branch 0 taken 1033 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1033 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1033 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1033 times.
✗ Branch 7 not taken.
2066 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11625 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11626 1033 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11627
2/4
✓ Branch 0 taken 1033 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1033 times.
✗ Branch 3 not taken.
1033 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11628 1033 sfx(itm.usesound,pan(wx));
11629 1033 attack=wFire;
11630 }
11631 1033 break;
11632
11633 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11634 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11635 {
11636 int32_t wtype = wScript1 + (itm.family-itype_script1);
11637 if(Lwpns.idCount(wtype))
11638 return false;
11639
11640 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11641 {
11642 return item_error();
11643 }
11644
11645 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
11646 paymagiccost(itemid);
11647
11648 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11649 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11650 sfx(itm.usesound,pan(wx));
11651 }
11652 break;
11653
11654 case itype_icerod:
11655 {
11656 if(Lwpns.idCount(wIce))
11657 return false;
11658
11659 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11660 {
11661 return item_error();
11662 }
11663
11664 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
11665 paymagiccost(itemid);
11666
11667 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11668 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11669 sfx(itm.usesound,pan(wx));
11670 }
11671 break;
11672
11673 case itype_arrow:
11674 {
11675
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 950 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 907 times.
950 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
11676 43 return false;
11677
11678
2/4
✓ Branch 0 taken 907 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 907 times.
907 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11679 {
11680 return item_error();
11681 }
11682
11683 907 paymagiccost(itemid);
11684
11685
6/12
✓ Branch 0 taken 907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 907 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 907 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 907 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 907 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 907 times.
✗ Branch 11 not taken.
907 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11686 907 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11687 907 sfx(itm.usesound,pan(wx));
11688 }
11689 907 break;
11690
11691 case itype_bait:
11692 {
11693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11694 return false;
11695
11696
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
11 if(!checkbunny(itemid))
11697 3 return item_error();
11698
11699
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
16 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11700
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11701
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11702
11703
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(!grumble && (itm.flags & ITEM_FLAG2))
11704 return item_error(); //Only usable for grumble rooms
11705
11706
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(checkcost && !checkmagiccost(itemid))
11707 return item_error();
11708
11709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paycost)
11710 8 paymagiccost(itemid);
11711 8 sfx(itm.usesound,pan(wx));
11712
11713
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(grumble)
11714 {
11715
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11716 8 fadeclk=66;
11717 8 dismissmsg();
11718 8 clear_bitmap(pricesdisplaybuf);
11719 8 set_clip_state(pricesdisplaybuf, 1);
11720 // putscr(scrollbuf,0,0,tmpscr);
11721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11723 {
11724 8 removeItemsOfFamily(game,itemsbuf,itype_bait);
11725 8 verifyBothWeapons();
11726 8 }
11727 8 sfx(tmpscr->secretsfx);
11728 8 return false;
11729 }
11730
11731 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11732 break;
11733 }
11734
11735 case itype_brang:
11736 {
11737
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 9573 times.
9864 if(Lwpns.idCount(wBrang) > itm.misc2)
11738 291 return false;
11739
11740
2/4
✓ Branch 0 taken 9573 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9573 times.
9573 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11741 {
11742 return item_error();
11743 }
11744
11745 9573 paymagiccost(itemid);
11746 9573 current_item_power(itype_brang);
11747
6/12
✓ Branch 0 taken 9573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9573 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9573 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9573 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9573 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9573 times.
✗ Branch 11 not taken.
9573 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11748 }
11749 9573 break;
11750
11751 case itype_hookshot:
11752 case itype_switchhook:
11753 {
11754
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(inlikelike || Lwpns.idCount(wHookshot))
11755 return false;
11756
11757
2/4
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225 times.
225 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11758 {
11759 return item_error();
11760 }
11761 225 bool sw = itm.family == itype_switchhook;
11762
11763
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
225 if(sw && (itm.flags&ITEM_FLAG8))
11764 switchhook_cost_item = itemid;
11765 225 else paymagiccost(itemid);
11766
11767 225 bool use_hookshot=true;
11768 225 bool hit_hs = false, hit_solid = false, insta_switch = false;
11769
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11770 225 int32_t cpos = -1, ffcpos = -1;
11771
4/4
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 225 times.
468 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11772 {
11773
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 49 times.
243 if(dir==up)
11774 {
11775
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
49 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11776 1 hit_hs = true;
11777 49 }
11778
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 155 times.
194 else if(dir==down)
11779 {
11780
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11781 hit_hs = true;
11782 39 }
11783
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 89 times.
155 else if(dir==left)
11784 {
11785
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11786 hit_hs = true;
11787 66 }
11788
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 else if(dir==right)
11789 {
11790
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11791 hit_hs = true;
11792 89 }
11793 //Diagonal Hookshot (6)
11794 else if(dir==r_down)
11795 {
11796 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11797 hit_hs = true;
11798 }
11799 else if(dir==l_down)
11800 {
11801 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11802 hit_hs = true;
11803 }
11804 else if(dir==r_up)
11805 {
11806 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11807 hit_hs = true;
11808 }
11809 else if(dir==l_up)
11810 {
11811 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11812 hit_hs = true;
11813 }
11814 243 }
11815
8/10
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 44 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 223 times.
✓ Branch 9 taken 2 times.
225 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11816 2 hit_solid = true;
11817
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1 times.
225 if(hit_hs)
11818 {
11819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(sw)
11820 insta_switch = true; //switch immediately
11821 1 else use_hookshot = false; //No hooking against grabbable
11822 1 }
11823
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 223 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
225 if(hit_solid && !insta_switch)
11824 2 use_hookshot = false;
11825
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 222 times.
225 if(use_hookshot)
11826 {
11827 222 int32_t hookitem = itm.fam_type;
11828 222 int32_t hookpower = itm.power;
11829 222 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11830
11831
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space())
11832 {
11833 Lwpns.del(0);
11834 }
11835
11836
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(!Lwpns.has_space(2))
11837 {
11838 Lwpns.del(0);
11839 }
11840
11841
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
222 switch(dir)
11842 {
11843 case up:
11844 {
11845 46 hookshot_used=true;
11846 46 hs_switcher = sw;
11847
4/8
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11848
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11849 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11850
5/10
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 46 times.
✗ Branch 9 not taken.
92 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11851
2/4
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
46 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11852 46 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11853 46 hs_startx=wx;
11854 46 hs_starty=wy-4;
11855 }
11856 46 break;
11857
11858 case down:
11859 {
11860 39 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
11861 39 hookshot_used=true;
11862 39 hs_switcher = sw;
11863
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11864
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11865 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11866
5/10
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 39 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 39 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 39 times.
✗ Branch 9 not taken.
78 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11867
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11868 39 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11869 39 hs_startx=wx;
11870 39 hs_starty=wy;
11871 }
11872 39 break;
11873
11874 case left:
11875 {
11876 54 hookshot_used=true;
11877 54 hs_switcher = sw;
11878
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11879
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11880 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11881
4/8
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
108 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11882
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11883 54 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11884 54 hs_startx=wx-4;
11885 54 hs_starty=wy;
11886 }
11887 54 break;
11888
11889 case right:
11890 {
11891 83 hookshot_used=true;
11892 83 hs_switcher = sw;
11893
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11894
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11895 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11896
4/8
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 83 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 83 times.
✗ Branch 7 not taken.
166 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11897
2/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
83 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11898 83 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11899 83 hs_startx=wx+4;
11900 83 hs_starty=wy;
11901 }
11902 83 break;
11903 //Diagonal Hookshot (7)
11904 case r_down:
11905 {
11906 hookshot_used=true;
11907 hs_switcher = sw;
11908 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
11909 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11910 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11911 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11912 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11913 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11914 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11915 hs_startx=wx+4;
11916 hs_starty=wy;
11917 }
11918 break;
11919
11920 case r_up:
11921 {
11922 hookshot_used=true;
11923 hs_switcher = sw;
11924 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11925 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11926 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11927 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11928 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11929 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11930 hs_startx=wx+4;
11931 hs_starty=wy;
11932 }
11933 break;
11934
11935 case l_down:
11936 {
11937 hookshot_used=true;
11938 hs_switcher = sw;
11939 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
11940 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11941 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11942 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11943 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11944 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11945 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11946 hs_startx=wx+4;
11947 hs_starty=wy;
11948 }
11949 break;
11950
11951 case l_up:
11952 {
11953 hookshot_used=true;
11954 hs_switcher = sw;
11955 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11956 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11957 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11958 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11959 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11960 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11961 hs_startx=wx+4;
11962 hs_starty=wy;
11963 }
11964 break;
11965 }
11966 222 hookshot_frozen=true;
11967 222 }
11968
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(insta_switch)
11969 {
11970 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11971 if (cpos > -1) hooked_combopos = cpos;
11972 if (ffcpos > -1)
11973 {
11974 switching_object = &(tmpscr->ffcs[ffcpos]);
11975 switching_object->switch_hooked = true;
11976 }
11977 w->misc=2;
11978 w->step=0;
11979 doSwitchHook(itm.misc5);
11980 if(itm.usesound2)
11981 sfx(itm.usesound2,pan(int32_t(x)));
11982 else if(QMisc.miscsfx[sfxSWITCHED])
11983 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11984 stop_sfx(itm.usesound);
11985 }
11986 }
11987 225 break;
11988
11989 case itype_divinefire:
11990 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11991 return false;
11992
11993 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11994 {
11995 return item_error();
11996 }
11997
11998 paymagiccost(itemid);
11999 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12000 else {action=casting; FFCore.setHeroAction(casting);}
12001 magicitem=itemid;
12002 break;
12003
12004 case itype_divineescape:
12005 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
12006 return false;
12007
12008 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12009 {
12010 return item_error();
12011 }
12012
12013 paymagiccost(itemid);
12014 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12015 else {action=casting; FFCore.setHeroAction(casting);}
12016 magicitem=itemid;
12017 break;
12018
12019 case itype_divineprotection:
12020 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
12021 return false;
12022
12023 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12024 {
12025 return item_error();
12026 }
12027
12028 paymagiccost(itemid);
12029 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12030 else {action=casting; FFCore.setHeroAction(casting);}
12031 magicitem=itemid;
12032 break;
12033
12034 case itype_cbyrna:
12035 {
12036 //Beams already deployed
12037
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
12038 {
12039 2 stopCaneOfByrna();
12040 2 return false;
12041 }
12042
12043
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12044 {
12045 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
12046 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
12047 return false;
12048 }
12049
12050 2 paymagiccost(itemid);
12051 2 last_cane_of_byrna_item_id = itemid;
12052 //zprint("itm.misc3: %d\n", itm.misc3);
12053
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
12054 {
12055 //byrna weapons are added here
12056 //space them apart
12057 //zprint("Added byrna weapon %d.\n", i);
12058 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
12059 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
12060
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12061 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12062 //wx += cos(2 * PI / (itm.misc3-i));
12063 //wy += sin(2 * PI / (itm.misc3-i));
12064 2 }
12065
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
12066 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
12067 }
12068 2 break;
12069
12070 case itype_clock:
12071 {
12072 ret = false;
12073 if(!(itm.flags & ITEM_FLAG1))
12074 break; //Passive clock, don't use
12075 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
12076 break;
12077 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
12078 {
12079 return item_error();
12080 }
12081
12082 paymagiccost(itemid);
12083
12084 setClock(watch=true);
12085
12086 for(int32_t i=0; i<eMAXGUYS; i++)
12087 clock_zoras[i]=0;
12088
12089 clockclk=itm.misc1;
12090 sfx(itm.usesound);
12091 break;
12092 }
12093 case itype_killem:
12094 {
12095 ret = false;
12096 if(!(itm.flags & ITEM_FLAG1))
12097 break; //Passive killemall, don't use
12098
12099 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12100 || !can_kill_em_all()) //No enemies onscreen
12101 {
12102 return item_error();
12103 }
12104
12105 paymagiccost(itemid);
12106
12107 kill_em_all();
12108 sfx(itm.usesound);
12109 break;
12110 }
12111 case itype_refill:
12112 {
12113 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12114 {
12115 return item_error();
12116 }
12117
12118 bool did_something = false;
12119
12120 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
12121 {
12122 if(swordclk)
12123 did_something = true;
12124 swordclk = 0;
12125 verifyAWpn();
12126 }
12127 for(auto q = 0; q < 5; ++q)
12128 {
12129 auto ctr = itm.misc(q);
12130 if(unsigned(ctr) >= MAX_COUNTERS)
12131 continue;
12132 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12133 if(!amnt) continue;
12134 bool gradual = itm.flags & ITEM_FLAG2;
12135 if(amnt > 0)
12136 {
12137 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12138 {
12139 //Can't *do* anything... skip
12140 continue;
12141 }
12142 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12143 {
12144 //Can't do anything unless affecting dcounter
12145 gradual = true;
12146 }
12147 }
12148 else //Negative
12149 {
12150 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12151 {
12152 //Can't *do* anything... skip
12153 continue;
12154 }
12155 if(game->get_counter(ctr) <= 0)
12156 {
12157 //Can't do anything unless affecting dcounter
12158 gradual = true;
12159 }
12160 }
12161 did_something = true;
12162 if(gradual) //Gradual
12163 {
12164 game->change_dcounter(amnt, ctr);
12165 }
12166 else
12167 {
12168 game->change_counter(amnt, ctr);
12169 }
12170 }
12171 if(!did_something)
12172 {
12173 return item_error();
12174 }
12175 paymagiccost(itemid);
12176 sfx(itm.usesound);
12177 ret = false;
12178 break;
12179 }
12180
12181 default:
12182 1163 ret = false;
12183 1163 }
12184
12185
2/2
✓ Branch 0 taken 25653 times.
✓ Branch 1 taken 23 times.
25676 if(itm.flags & ITEM_DOWNGRADE)
12186 {
12187 23 game->set_item(itemid,false);
12188
12189 // Maybe Item Override has allowed the same item in both slots?
12190
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Bwpn == itemid)
12191 {
12192 Bwpn = 0;
12193 game->forced_bwpn = -1;
12194 verifyBWpn();
12195 }
12196
12197
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Awpn == itemid)
12198 {
12199 Awpn = 0;
12200 game->forced_awpn = -1;
12201 verifyAWpn();
12202 }
12203
12204
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Xwpn == itemid)
12205 {
12206 Xwpn = 0;
12207 game->forced_xwpn = -1;
12208 verifyXWpn();
12209 }
12210
12211
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Ywpn == itemid)
12212 {
12213 Ywpn = 0;
12214 game->forced_ywpn = -1;
12215 verifyYWpn();
12216 }
12217 23 }
12218
12219 25676 return ret;
12220 30912 }
12221
12222
12223 956872 bool HeroClass::doattack()
12224 {
12225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 956872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
956872 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12226 return false;
12227 //int32_t s = BSZ ? 0 : 11;
12228 956872 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12229
12230
3/4
✓ Branch 0 taken 31566 times.
✓ Branch 1 taken 925306 times.
✓ Branch 2 taken 31566 times.
✗ Branch 3 not taken.
956872 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 956872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
956872 if(attack==wBugNet && bugnetid!=-1)
12232 {
12233 if(++attackclk >= NET_CLK_TOTAL)
12234 return false;
12235
12236 return true;
12237 }
12238
12239 // Abort attack if attackclk has run out and:
12240 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12241 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12242
12243
6/6
✓ Branch 0 taken 64273 times.
✓ Branch 1 taken 892599 times.
✓ Branch 2 taken 52004 times.
✓ Branch 3 taken 12269 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3627 times.
962786 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12244
12/12
✓ Branch 0 taken 43703 times.
✓ Branch 1 taken 8301 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 40117 times.
✓ Branch 4 taken 46885 times.
✓ Branch 5 taken 5119 times.
✓ Branch 6 taken 46090 times.
✓ Branch 7 taken 795 times.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 2329 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1321 times.
52004 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12245 {
12246 49717 tapping=false;
12247 49717 return false;
12248 }
12249
12250
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 906434 times.
907155 if(attackclk>29)
12251 {
12252 721 tapping=false;
12253 721 return false;
12254 }
12255
12256
4/4
✓ Branch 0 taken 29575 times.
✓ Branch 1 taken 876859 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1876 times.
906434 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12257
3/4
✓ Branch 0 taken 29575 times.
✓ Branch 1 taken 876859 times.
✓ Branch 2 taken 29575 times.
✗ Branch 3 not taken.
906434 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12258 // An attack can be "walked out-of" after 8 frames, unless it's:
12259 // * a sword stab
12260 // * a hammer pound
12261 // * a wand thrust
12262 // * a candle thrust
12263 // * a cane thrust
12264 // In which case it should continue.
12265
8/8
✓ Branch 0 taken 47898 times.
✓ Branch 1 taken 858536 times.
✓ Branch 2 taken 116442 times.
✓ Branch 3 taken 68544 times.
✓ Branch 4 taken 800259 times.
✓ Branch 5 taken 126821 times.
✓ Branch 6 taken 200710 times.
✓ Branch 7 taken 599549 times.
1085035 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12266
5/6
✓ Branch 0 taken 178631 times.
✓ Branch 1 taken 22079 times.
✓ Branch 2 taken 13663 times.
✓ Branch 3 taken 164968 times.
✓ Branch 4 taken 13663 times.
✗ Branch 5 not taken.
200710 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12267
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 164938 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
178631 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12268
2/2
✓ Branch 0 taken 178601 times.
✓ Branch 1 taken 13663 times.
164968 && (attack != wBugNet) && attackclk>7))
12269 {
12270
8/8
✓ Branch 0 taken 59056 times.
✓ Branch 1 taken 3103 times.
✓ Branch 2 taken 56434 times.
✓ Branch 3 taken 2622 times.
✓ Branch 4 taken 53304 times.
✓ Branch 5 taken 3130 times.
✓ Branch 6 taken 3309 times.
✓ Branch 7 taken 49995 times.
295043 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12271 {
12272 12164 lstep = s;
12273 12164 return false;
12274 }
12275 49995 }
12276
12277
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 823884 times.
825800 if(charging==0)
12278 {
12279 823884 lstep=0;
12280 823884 }
12281
12282 // Work out the sword charge-up delay
12283 825800 int32_t magiccharge = 192, normalcharge = 64;
12284 825800 int32_t itemid = current_item_id(itype_chargering);
12285
12286
2/2
✓ Branch 0 taken 786733 times.
✓ Branch 1 taken 39067 times.
825800 if(itemid>=0)
12287 {
12288 39067 normalcharge = itemsbuf[itemid].misc1;
12289 39067 magiccharge = itemsbuf[itemid].misc2;
12290 39067 }
12291
12292 825800 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12293 825800 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12294
12295 825800 bool doCharge=true;
12296
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 825800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
825800 if(z!=0 && fakez != 0)
12297 doCharge=false;
12298
2/2
✓ Branch 0 taken 599549 times.
✓ Branch 1 taken 226251 times.
825800 if(attack==wSword)
12299 {
12300
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 597888 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
599549 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12301 597912 doCharge=false;
12302
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12303 {
12304
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12305 doCharge=false;
12306 1220 }
12307 599549 }
12308
2/2
✓ Branch 0 taken 22079 times.
✓ Branch 1 taken 204172 times.
226251 else if(attack==wHammer)
12309 {
12310
4/4
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 21330 times.
✓ Branch 2 taken 740 times.
✓ Branch 3 taken 9 times.
22079 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12311 22070 doCharge=false;
12312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(charging<=normalcharge)
12313 {
12314
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
9 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12315 1 doCharge=false;
12316 9 }
12317 22079 }
12318 else
12319 204172 doCharge=false;
12320
12321 // charging up weapon...
12322
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 824155 times.
825800 if(doCharge)
12323 {
12324 // Increase charging while holding down button.
12325
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12326 1517 charging++;
12327
12328 // Once a charging threshold is reached, play the sound.
12329
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12330 {
12331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
12332 9 paymagiccost(scrollid);
12333 9 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12334 9 }
12335
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12336 {
12337
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12338 {
12339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
12340 3 paymagiccost(scroll2id);
12341 3 charging++; // charging>magiccharge signifies a successful supercharge.
12342 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12343 3 }
12344 3 }
12345 1645 }
12346
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 824125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
824155 else if(attack==wCByrna && byrnaid!=-1)
12347 {
12348
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12349 {
12350 attack = wNone;
12351 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12352 }
12353
12354 30 bool beamcount = false;
12355
12356
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12357 {
12358 55 weapon *w = ((weapon*)Lwpns.spr(i));
12359
12360
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12361 {
12362 4 beamcount = true;
12363 4 break;
12364 }
12365 51 }
12366
12367 // If beams already deployed, remove them
12368
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12369 {
12370 2 return startwpn(attackid); // Remove beams instantly
12371 }
12372
12373 // Otherwise, continue
12374 28 ++attackclk;
12375 28 }
12376 else
12377 {
12378 824125 ++attackclk;
12379
12380
6/6
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 823327 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 773 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
824125 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12381 {
12382 14 ++attackclk; // Won't continue charging
12383 14 charging=0;
12384 14 }
12385
12386 // Faster if spinning.
12387
2/2
✓ Branch 0 taken 823533 times.
✓ Branch 1 taken 592 times.
824125 if(spins>0)
12388 592 ++attackclk;
12389
12390 // Even faster if hurricane spinning.
12391
2/2
✓ Branch 0 taken 823693 times.
✓ Branch 1 taken 432 times.
824125 if(spins>5)
12392 432 attackclk+=2;
12393
12394 // If at a charging threshold, do a charged attack.
12395
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 824011 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
824125 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12396 {
12397
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12398 {
12399
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 bool super = charging>magiccharge && scroll2id > -1;
12400
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 int id = super ? scroll2id : scrollid;
12401 8 itemdata const& spinscroll = itemsbuf[id];
12402 8 bool paid = !(spinscroll.flags&ITEM_FLAG1);
12403
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 if(!paid && checkbunny(id) && checkmagiccost(id))
12404 {
12405 paid = true;
12406 paymagiccost(id);
12407 }
12408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paid)
12409 {
12410 8 currentscroll = id;
12411 8 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12412 8 attackclk=1;
12413 8 sfx(spinscroll.usesound,pan(x.getInt()));
12414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(spinscroll.flags&ITEM_FLAG1)
12415 paymagiccost(id);
12416 8 }
12417 8 }
12418 else if(attack==wHammer && sideviewhammerpound())
12419 {
12420 bool super = charging>magiccharge && scroll2id > -1;
12421 int id = super ? scroll2id : scrollid;
12422 itemdata const& quakescroll = itemsbuf[id];
12423 bool paid = !(quakescroll.flags&ITEM_FLAG1);
12424 if(!paid && checkbunny(id) && checkmagiccost(id))
12425 {
12426 paid = true;
12427 paymagiccost(id);
12428 }
12429 if(paid)
12430 {
12431 currentscroll = id;
12432 spins = super ? 2 : 1;
12433 sfx(quakescroll.usesound,pan(x.getInt()));
12434 quakeclk=quakescroll.misc1;
12435
12436 // general area stun
12437 for(int32_t i=0; i<GuyCount(); i++)
12438 {
12439 if(!isflier(GuyID(i)))
12440 {
12441 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12442 }
12443 }
12444
12445 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12446 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12447 if(hmrlvl < 1) hmrlvl = 1;
12448 int rad = quakescroll.misc2;
12449 for(int pos = 0; pos < 176; ++pos)
12450 {
12451 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
12452 for(int lyr = 0; lyr < 7; ++lyr)
12453 {
12454 int cid = FFCore.tempScreens[lyr]->data[pos];
12455 newcombo const& cmb = combobuf[cid];
12456 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12457 {
12458 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12459 ? hmrlvl <= cmb.triggerlevel
12460 : hmrlvl >= cmb.triggerlevel)
12461 do_trigger_combo(lyr,pos);
12462 }
12463 }
12464 }
12465 word c = tmpscr->numFFC();
12466 for(int ff = 0; ff < c; ++ff)
12467 {
12468 ffcdata& ffc = tmpscr->ffcs[ff];
12469 newcombo const& cmb = combobuf[ffc.getData()];
12470 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
12471 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12472 {
12473 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12474 ? hmrlvl <= cmb.triggerlevel
12475 : hmrlvl >= cmb.triggerlevel)
12476 do_trigger_combo_ffc(ff);
12477 }
12478 }
12479 }
12480 }
12481 8 }
12482
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 824002 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
824117 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12483 48 charging++;
12484
12485
7/8
✓ Branch 0 taken 13425 times.
✓ Branch 1 taken 810700 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 810700 times.
✓ Branch 4 taken 21500 times.
✓ Branch 5 taken 789200 times.
✓ Branch 6 taken 477588 times.
✓ Branch 7 taken 346537 times.
824125 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12486 346537 charging=0;
12487
12488
2/2
✓ Branch 0 taken 816026 times.
✓ Branch 1 taken 8099 times.
824125 if(attackclk>=SWORDCHARGEFRAME)
12489 8099 tapping = false;
12490 }
12491
12492
6/8
✓ Branch 0 taken 65367 times.
✓ Branch 1 taken 760431 times.
✓ Branch 2 taken 1130 times.
✓ Branch 3 taken 64237 times.
✓ Branch 4 taken 1130 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1130 times.
825798 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12493 {
12494 1130 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12495 }
12496
12497 824668 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12498
12499
11/14
✓ Branch 0 taken 773739 times.
✓ Branch 1 taken 50929 times.
✓ Branch 2 taken 59105 times.
✓ Branch 3 taken 714634 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 59073 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
824668 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12500 {
12501
12502
4/4
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 48934 times.
✓ Branch 2 taken 582 times.
✓ Branch 3 taken 1425 times.
50941 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12503
2/2
✓ Branch 0 taken 50917 times.
✓ Branch 1 taken 24 times.
50941 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12504
12505
4/4
✓ Branch 0 taken 50917 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 5323 times.
✓ Branch 3 taken 45594 times.
50941 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12506 {
12507 45594 templife=templife*game->get_maxlife();
12508 45594 templife=templife/100;
12509 45594 }
12510 else
12511 {
12512 5347 templife*=game->get_hp_per_heart();
12513 }
12514
12515
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 33763 times.
50941 bool normalbeam = (int64_t(game->get_life())+(get_qr(qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12516 50941 int32_t perilid = current_item_id(itype_perilscroll);
12517
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 49304 times.
✓ Branch 2 taken 1637 times.
✗ Branch 3 not taken.
50944 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12518
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
1637 && checkbunny(perilid) && checkmagiccost(perilid)
12519 // Must actually be able to shoot sword beams
12520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12521
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12522
12523
4/4
✓ Branch 0 taken 41591 times.
✓ Branch 1 taken 9350 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 41572 times.
50941 if(attack==wSword && !tapping)
12524 {
12525
4/4
✓ Branch 0 taken 41569 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 13332 times.
✓ Branch 3 taken 28237 times.
41572 if(perilbeam || normalbeam)
12526 {
12527
1/2
✓ Branch 0 taken 13335 times.
✗ Branch 1 not taken.
13335 if(attackclk==7)
12528 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12529
12530
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
13335 if(perilbeam && !normalbeam)
12531 3 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12532
12533 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12534 // a way to make the peril/cross beam item's power stat influence the strength
12535 // of the peril/cross beam...
12536 13335 startwpn(attackid);
12537 13335 }
12538 28237 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12539 41572 }
12540
12541
2/2
✓ Branch 0 taken 49406 times.
✓ Branch 1 taken 1535 times.
50941 if(attack==wWand)
12542 1535 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12543
12544
4/6
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 50123 times.
✓ Branch 2 taken 818 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 818 times.
✗ Branch 5 not taken.
50941 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12545 startwpn(attackid);
12546
12547
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50939 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
50941 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12548 2 startwpn(attackid);
12549 50941 }
12550
12551
2/2
✓ Branch 0 taken 774260 times.
✓ Branch 1 taken 50408 times.
824668 if(attackclk==14)
12552 50408 lstep = s;
12553
12554 824668 return true;
12555 888402 }
12556
12557 13784414 bool HeroClass::can_attack()
12558 {
12559
4/4
✓ Branch 0 taken 13575084 times.
✓ Branch 1 taken 209330 times.
✓ Branch 2 taken 7977602 times.
✓ Branch 3 taken 5597482 times.
13784414 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12560
4/6
✓ Branch 0 taken 13784414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13652044 times.
✓ Branch 3 taken 132370 times.
✓ Branch 4 taken 13652044 times.
✗ Branch 5 not taken.
14696048 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12561
5/8
✓ Branch 0 taken 13652044 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13652044 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13652044 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13650348 times.
✓ Branch 7 taken 1696 times.
13652044 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12562
3/4
✓ Branch 0 taken 13650348 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11957772 times.
✓ Branch 3 taken 1692576 times.
13650348 || ((action==attacking||action==sideswimattacking)
12563
2/2
✓ Branch 0 taken 455824 times.
✓ Branch 1 taken 13194524 times.
13650348 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12564
2/2
✓ Branch 0 taken 13650334 times.
✓ Branch 1 taken 455810 times.
13650348 && charging!=0))
12565 {
12566 1045700 return false;
12567 }
12568
12569 13650334 int32_t r = (isdungeon()) ? 16 : 0;
12570 13650334 int32_t r2 = get_qr(qr_NOBORDER) ? 0 : 8;
12571
12572
4/5
✓ Branch 0 taken 3798052 times.
✓ Branch 1 taken 9852282 times.
✓ Branch 2 taken 4369854 times.
✓ Branch 3 taken 5482428 times.
✗ Branch 4 not taken.
13650334 if(!get_qr(qr_ITEMSONEDGES)) switch(dir)
12573 {
12574 case up:
12575 case down:
12576
2/2
✓ Branch 0 taken 4201600 times.
✓ Branch 1 taken 168254 times.
4369854 return !(y<(r2+r) || y>(160-r-r2));
12577
12578 case left:
12579 case right:
12580
2/2
✓ Branch 0 taken 5317066 times.
✓ Branch 1 taken 165362 times.
5482428 return !(x<(r2+r) || x>(240-r-r2));
12581 }
12582
12583 3798052 return true;
12584 14696034 }
12585
12586 9394 bool isRaftFlag(int32_t flag)
12587 {
12588
4/4
✓ Branch 0 taken 4742 times.
✓ Branch 1 taken 4652 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 4506 times.
9394 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12589 }
12590
12591 3914100 void handle_lens_triggers(int32_t l_id)
12592 {
12593
2/2
✓ Branch 0 taken 3907841 times.
✓ Branch 1 taken 6259 times.
3914100 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12594
2/2
✓ Branch 0 taken 3914100 times.
✓ Branch 1 taken 27398700 times.
31312800 for(auto layer = 0; layer < 7; ++layer)
12595 {
12596 27398700 mapscr* tmp = FFCore.tempScreens[layer];
12597
2/2
✓ Branch 0 taken 4822171200 times.
✓ Branch 1 taken 27398700 times.
4849569900 for(auto pos = 0; pos < 176; ++pos)
12598 {
12599 4822171200 newcombo const& cmb = combobuf[tmp->data[pos]];
12600
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 4821890304 times.
✓ Branch 2 taken 4822171014 times.
✓ Branch 3 taken 186 times.
4822171200 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12601 4821890304 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12602 {
12603 186 do_trigger_combo(layer, pos);
12604 186 }
12605 4822171200 }
12606 27398700 }
12607
2/2
✓ Branch 0 taken 3760970 times.
✓ Branch 1 taken 153130 times.
3914100 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
12608 {
12609 153130 word c = tmpscr->numFFC();
12610
2/2
✓ Branch 0 taken 631324 times.
✓ Branch 1 taken 153130 times.
784454 for(word i=0; i<c; i++)
12611 {
12612 631324 ffcdata& ffc = tmpscr->ffcs[i];
12613 631324 newcombo const& cmb = combobuf[ffc.getData()];
12614
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 629728 times.
✓ Branch 2 taken 631324 times.
✗ Branch 3 not taken.
631324 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12615 629728 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12616 {
12617 do_trigger_combo_ffc(i);
12618 }
12619 631324 }
12620 153130 }
12621 3914100 }
12622
12623 6967491 void do_lens()
12624 {
12625
2/2
✓ Branch 0 taken 3053391 times.
✓ Branch 1 taken 3914100 times.
6967491 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12626 {
12627 3053391 do_210_lens();
12628 3053391 return;
12629 }
12630
12631 3914100 int32_t wpnPressed = getWpnPressed(itype_lens);
12632
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 3907844 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 3907469 times.
✓ Branch 4 taken 390142 times.
✓ Branch 5 taken 3517327 times.
3914100 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12633
2/2
✓ Branch 0 taken 2983786 times.
✓ Branch 1 taken 930314 times.
3914100 if(itemid >= 0)
12634 {
12635
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 924971 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
930314 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12636 {
12637
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
12638 {
12639 209 lensid=itemid;
12640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
12641 209 Hero.setLastLensID(itemid);
12642
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12643 209 }
12644
12645 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12646
12647
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
12648 {
12649 //clear the item script stack for a new script
12650 int i = itemid;
12651 FFCore.reset_script_engine_data(ScriptType::Item, i);
12652 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
12653 did_scriptl=true;
12654 }
12655
12656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12657 527 else lensclk = 12;
12658 527 }
12659 else
12660 {
12661 929787 did_scriptl=false;
12662
2/2
✓ Branch 0 taken 924055 times.
✓ Branch 1 taken 5732 times.
929787 if(!lensclk)
12663 {
12664
12665
2/2
✓ Branch 0 taken 923849 times.
✓ Branch 1 taken 206 times.
924055 if(lensid>-1)
12666 {
12667 206 lensid=-1;
12668 206 lensclk = 0;
12669
12670
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12671 206 }
12672 924055 }
12673 }
12674 930314 }
12675 3914100 handle_lens_triggers(lensid);
12676 6967491 }
12677 //Add 2.10 version check to call this
12678 3053391 void do_210_lens()
12679 {
12680
3/4
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 3051711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051711 times.
3053391 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12681
12682
2/2
✓ Branch 0 taken 367843 times.
✓ Branch 1 taken 2685548 times.
3053391 if(itemid<0)
12683 2685548 return;
12684
12685
6/8
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 366163 times.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 1432 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 248 times.
367843 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12686 {
12687
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 234 times.
248 if(lensid<0)
12688 {
12689 234 lensid=itemid;
12690
12691
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12692 234 }
12693
12694 248 paymagiccost(itemid, true);
12695
12696
2/10
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
248 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
12697 {
12698 //clear the item script stack for a new script
12699 int i = itemid;
12700 FFCore.reset_script_engine_data(ScriptType::Item, i);
12701 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
12702 did_scriptl=true;
12703 }
12704
12705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12706 248 else lensclk = 12;
12707 248 }
12708 else
12709 {
12710 367595 did_scriptl=false;
12711
12712
6/8
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 365929 times.
✓ Branch 2 taken 1432 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1432 times.
✗ Branch 7 not taken.
367595 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12713 {
12714 234 lensid=-1;
12715 234 lensclk = 0;
12716
12717
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12718 234 }
12719 }
12720 3053391 }
12721
12722 6327 void HeroClass::do_hopping()
12723 {
12724 6327 do_lens();
12725
12726
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 6138 times.
6327 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12727 //Possible fix for exiting water in diagonal movement. -Z
12728 {
12729 189 int32_t flippers_id = current_item_id(itype_flippers);
12730
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 186 times.
189 if(diveclk>0)
12731 {
12732 3 --diveclk;
12733
2/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12734 {
12735 diveclk = itemsbuf[flippers_id].misc2;
12736 }
12737 3 }
12738
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 1 times.
186 else if(DrunkrAbtn())
12739 {
12740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12741 1 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12742
12743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(global_diving==screen_diving)
12744
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12745 1 }
12746
12747
3/8
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
189 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12748 {
12749 189 SetSwim();
12750 189 hopclk = 0;
12751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (!IsSideSwim())
12752 {
12753 189 charging = attackclk = 0;
12754 189 tapping = false;
12755 189 }
12756 189 }
12757 else
12758 {
12759 herostep();
12760
12761 if(!isDiving() || (frame&1))
12762 {
12763 switch(dir)
12764 {
12765 case up:
12766 y -= 1;
12767 break;
12768
12769 case down:
12770 y += 1;
12771 break;
12772
12773 case left:
12774 x -= 1;
12775 break;
12776
12777 case right:
12778 x += 1;
12779 break;
12780 }
12781 }
12782 }
12783 189 }
12784 else // hopping in or out (need to separate the cases...)
12785 {
12786
4/6
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 5850 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5850 times.
6138 if((diagonalMovement||NO_GRIDLOCK))
12787 {
12788
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 204 times.
288 if(hopclk==1) //hopping out
12789 //>= 1 possible fix for getting stuck on land edges.
12790 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12791 {
12792
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 if(hopdir!=-1) dir=hopdir;
12793
12794 204 landswim=0;
12795
12796
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 87 times.
204 if(dir==up)
12797 {
12798 87 herostep();
12799 87 herostep();
12800 87 int32_t sidestep=0;
12801
12802
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 87 times.
87 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12803 sidestep=1;
12804
3/6
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 87 times.
✗ Branch 5 not taken.
87 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12805 sidestep=2;
12806
12807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 if(sidestep==1) x++;
12808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 else if(sidestep==2) x--;
12809 87 else y--;
12810
12811
3/4
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 6 times.
87 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12812 {
12813 6 hopclk=0;
12814 6 diveclk=0;
12815 6 action=none; FFCore.setHeroAction(none);
12816 6 hopdir=-1;
12817 6 }
12818 87 }
12819
12820
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 58 times.
204 if(dir==down)
12821 {
12822 58 herostep();
12823 58 herostep();
12824 58 int32_t sidestep=0;
12825
12826
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 58 times.
58 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12827 sidestep=1;
12828
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12829 sidestep=2;
12830
12831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if(sidestep==1) x++;
12832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 else if(sidestep==2) x--;
12833 58 else y++;
12834
12835
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
58 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12836 {
12837 4 hopclk=0;
12838 4 diveclk=0;
12839 4 action=none; FFCore.setHeroAction(none);
12840 4 hopdir=-1;
12841 4 }
12842 58 }
12843
12844
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 15 times.
204 if(dir==left)
12845 {
12846 15 herostep();
12847 15 herostep();
12848 15 int32_t sidestep=0;
12849
12850
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
15 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12851 sidestep=1;
12852
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12853 sidestep=2;
12854
12855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(sidestep==1) y++;
12856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 else if(sidestep==2) y--;
12857 15 else x--;
12858
12859
3/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1 times.
15 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12860 {
12861 1 hopclk=0;
12862 1 diveclk=0;
12863 1 action=none; FFCore.setHeroAction(none);
12864 1 hopdir=-1;
12865 1 }
12866 15 }
12867
12868
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 44 times.
204 if(dir==right)
12869 {
12870 44 herostep();
12871 44 herostep();
12872 44 int32_t sidestep=0;
12873
12874
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 44 times.
44 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12875 sidestep=1;
12876
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
44 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12877 sidestep=2;
12878
12879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(sidestep==1) y++;
12880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 else if(sidestep==2) y--;
12881 44 else x++;
12882
12883
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
44 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12884 {
12885 3 hopclk=0;
12886 3 diveclk=0;
12887 3 action=none; FFCore.setHeroAction(none);
12888 3 hopdir=-1;
12889 3 }
12890 44 }
12891 204 }
12892
12893
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 84 times.
288 if(hopclk==2) //hopping in
12894 {
12895 84 landswim=0;
12896
12897
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 42 times.
84 if(dir==up)
12898 {
12899 42 herostep();
12900 42 herostep();
12901 42 int32_t sidestep=0;
12902
12903
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 42 times.
42 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12904 sidestep=1;
12905
3/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 42 times.
✗ Branch 5 not taken.
42 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12906 sidestep=2;
12907
12908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(sidestep==1) x++;
12909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 else if(sidestep==2) x--;
12910 42 else y--;
12911
12912
3/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 3 times.
42 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12913 {
12914 3 hopclk=0xFF;
12915 3 diveclk=0;
12916 3 SetSwim();
12917 3 }
12918 42 }
12919
12920
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(dir==down)
12921 {
12922 herostep();
12923 herostep();
12924 int32_t sidestep=0;
12925
12926 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12927 sidestep=1;
12928 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12929 sidestep=2;
12930
12931 if(sidestep==1) x++;
12932 else if(sidestep==2) x--;
12933 else y++;
12934
12935 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12936 {
12937 hopclk=0xFF;
12938 diveclk=0;
12939 SetSwim();
12940 if (!IsSideSwim()) reset_swordcharge();
12941 }
12942 }
12943
12944
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 14 times.
84 if(dir==left)
12945 {
12946 14 herostep();
12947 14 herostep();
12948 14 int32_t sidestep=0;
12949
12950
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
14 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12951 sidestep=1;
12952
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
14 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12953 sidestep=2;
12954
12955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(sidestep==1) y++;
12956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(sidestep==2) y--;
12957 14 else x--;
12958
12959
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
14 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12960 {
12961 1 hopclk=0xFF;
12962 1 diveclk=0;
12963 1 SetSwim();
12964 1 }
12965 14 }
12966
12967
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(dir==right)
12968 {
12969 28 herostep();
12970 28 herostep();
12971
12972 28 int32_t sidestep=0;
12973
12974
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28 times.
28 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12975 sidestep=1;
12976
3/6
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
28 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12977 sidestep=2;
12978
12979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(sidestep==1) y++;
12980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 else if(sidestep==2) y--;
12981 28 else x++;
12982
12983
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
28 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12984 {
12985 2 hopclk=0xFF;
12986 2 diveclk=0;
12987 2 SetSwim();
12988 2 }
12989 28 }
12990 84 }
12991
12992 288 }
12993 else
12994 {
12995
7/8
✓ Branch 0 taken 2193 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 2193 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1624 times.
✓ Branch 5 taken 569 times.
✓ Branch 6 taken 310 times.
✓ Branch 7 taken 3347 times.
5850 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12996 {
12997 569 action=none; FFCore.setHeroAction(none);
12998 569 hopclk = 0;
12999 569 diveclk = 0;
13000
13001
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 292 times.
569 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
13002 {
13003 // hopped in
13004 292 SetSwim();
13005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if (!IsSideSwim()) attackclk = charging = spins = 0;
13006 292 }
13007 569 }
13008 else
13009 {
13010 5281 herostep();
13011 5281 herostep();
13012
13013
2/2
✓ Branch 0 taken 4972 times.
✓ Branch 1 taken 309 times.
5281 if(++hero_count>(16*hero_animation_speed))
13014 309 hero_count=0;
13015
13016 5281 int32_t xofs2 = x.getInt()&15;
13017 5281 int32_t yofs2 = y.getInt()&15;
13018 5281 int32_t s = 1 + (frame&1);
13019
13020
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
✓ Branch 2 taken 1201 times.
✓ Branch 3 taken 1561 times.
✓ Branch 4 taken 1786 times.
5281 switch(dir)
13021 {
13022 case up:
13023
3/4
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 214 times.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
733 if(yofs2<3 || yofs2>13) --y;
13024 519 else y-=s;
13025
13026 733 break;
13027
13028 case down:
13029
4/4
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 840 times.
1201 if(yofs2<3 || yofs2>13) ++y;
13030 840 else y+=s;
13031
13032 1201 break;
13033
13034 case left:
13035
4/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 260 times.
✓ Branch 3 taken 1105 times.
1561 if(xofs2<3 || xofs2>13) --x;
13036 1105 else x-=s;
13037
13038 1561 break;
13039
13040 case right:
13041
4/4
✓ Branch 0 taken 1485 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 237 times.
✓ Branch 3 taken 1248 times.
1786 if(xofs2<3 || xofs2>13) ++x;
13042 1248 else x+=s;
13043
13044 1786 break;
13045 }
13046 }
13047 }
13048 }
13049 6327 }
13050
13051 68957 void HeroClass::do_rafting()
13052 {
13053
13054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68957 times.
68957 if(toogam)
13055 {
13056 action=none; FFCore.setHeroAction(none);
13057 return;
13058 }
13059
13060 68957 FFCore.setHeroAction(rafting);
13061
13062 68957 do_lens();
13063
13064 68957 herostep();
13065
13066 //Calculate rafting speed
13067 68957 int32_t raft_item = current_item_id(itype_raft);
13068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68957 times.
68957 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
13069 68957 raft_step = vbound(raft_step, -8, 5);
13070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68957 times.
68957 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
13071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68957 times.
68957 if(raft_step < 0) raft_step = 1;
13072 68957 int32_t step_inc = 1 << (raft_step - 1);
13073 // Fix position
13074
1/2
✓ Branch 0 taken 68957 times.
✗ Branch 1 not taken.
68957 if(raft_step > 1)
13075 {
13076 if(x.getInt() & (step_inc-1))
13077 {
13078 x = x.getInt() & ~(step_inc-1);
13079 }
13080 if(y.getInt() & (step_inc-1))
13081 {
13082 y = y.getInt() & ~(step_inc-1);
13083 }
13084 }
13085 // Inc clock, check if we need to move this frame
13086 68957 ++raftclk;
13087
2/4
✓ Branch 0 taken 68957 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68957 times.
68957 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13088
13089
4/4
✓ Branch 0 taken 33797 times.
✓ Branch 1 taken 35160 times.
✓ Branch 2 taken 29104 times.
✓ Branch 3 taken 4693 times.
73523 if(!(x.getInt()&15) && !(y.getInt()&15))
13090 {
13091 // this sections handles switching to raft branches
13092
3/4
✓ Branch 0 taken 4458 times.
✓ Branch 1 taken 235 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4458 times.
4693 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13093 {
13094
7/8
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
235 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13095 {
13096 34 dir = up;
13097 34 goto skip;
13098 }
13099
13100
7/8
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 41 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
201 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13101 {
13102 41 dir = down;
13103 41 goto skip;
13104 }
13105
13106
7/8
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
160 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13107 {
13108 26 dir = left;
13109 26 goto skip;
13110 }
13111
13112
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
134 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13113 {
13114 26 dir = right;
13115 26 goto skip;
13116 }
13117 108 }
13118
2/4
✓ Branch 0 taken 4458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4458 times.
4458 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13119 {
13120 if(dir == left) dir = right;
13121 else if(dir == right) dir = left;
13122 else if(dir == up) dir = down;
13123 else if(dir == down) dir = up;
13124 }
13125
13126
13127
3/4
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 3678 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 888 times.
4566 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13128 {
13129
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 414 times.
888 if(dir<left) //going up or down
13130 {
13131
3/4
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 298 times.
474 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13132 176 dir=right;
13133
3/4
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
298 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13134 170 dir=left;
13135
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13 times.
128 else if(y>0 && y<160)
13136 {
13137 106 action=none; FFCore.setHeroAction(none);
13138 106 x = x.getInt();
13139 106 y = y.getInt();
13140 106 }
13141 474 }
13142 else //going left or right
13143 {
13144
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
414 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13145 170 dir=down;
13146
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
244 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13147 167 dir=up;
13148
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 else if(x>0 && x<240)
13149 {
13150 77 action=none; FFCore.setHeroAction(none);
13151 77 x = x.getInt();
13152 77 y = y.getInt();
13153 77 }
13154 }
13155 888 }
13156 4566 }
13157
13158 skip:
13159
13160
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15508 times.
✓ Branch 2 taken 15758 times.
✓ Branch 3 taken 18328 times.
✓ Branch 4 taken 19363 times.
68957 switch(dir)
13161 {
13162 case up:
13163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15508 times.
15508 if(x.getInt()&15)
13164 {
13165 if(x.getInt()&8)
13166 x++;
13167 else x--;
13168 }
13169 15508 else y -= step_inc;
13170
13171 15508 break;
13172
13173 case down:
13174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15758 times.
15758 if(x.getInt()&15)
13175 {
13176 if(x.getInt()&8)
13177 x++;
13178 else x--;
13179 }
13180 15758 else y += step_inc;
13181
13182 15758 break;
13183
13184 case left:
13185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18328 times.
18328 if(y.getInt()&15)
13186 {
13187 if (get_qr(qr_BETTER_RAFT_2))
13188 {
13189 if ((y.getInt() % 16) < 4) y--;
13190 else y++;
13191 }
13192 else
13193 {
13194 if(y.getInt()&8)
13195 y++;
13196 else y--;
13197 }
13198 }
13199 18328 else x -= step_inc;
13200
13201 18328 break;
13202
13203 case right:
13204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19363 times.
19363 if(y.getInt()&15)
13205 {
13206 if (get_qr(qr_BETTER_RAFT_2))
13207 {
13208 if ((y.getInt() % 16) <= 4) y--;
13209 else y++;
13210 }
13211 else
13212 {
13213 if(y.getInt()&8)
13214 y++;
13215 else y--;
13216 }
13217 }
13218 19363 else x += step_inc;
13219
13220 19363 break;
13221 }
13222 68957 }
13223
13224 28 bool HeroClass::try_hover()
13225 {
13226
6/10
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 26 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
28 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13227 {
13228 2 int32_t itemid = current_item_id(itype_hoverboots);
13229
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13230 hoverclk = -hoverclk;
13231 else
13232 {
13233 2 fall = fakefall = jumping = 0;
13234
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13235 2 hoverclk = itemsbuf[itemid].misc1;
13236 else
13237 {
13238 hoverclk = 1;
13239 hoverflags |= HOV_INF;
13240 }
13241
13242
13243 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13244 }
13245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13246
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13247 2 return true;
13248 }
13249 26 return false;
13250 28 }
13251
13252 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13253 //Returns '-1' if not being pulled
13254 //Returns '-2' if should be falling in
13255 27167116 int32_t HeroClass::check_pitslide(bool ignore_hover)
13256 {
13257 //Pitfall todo -Emily
13258 //Iron boots; can't fight slipping, 2px/frame
13259 //Scripted variables to read pull dir/clk (clk only for non-hero)
13260 //Implement falling for all sprite types (npc AI)
13261 // Fall/slipping tiles for enemies
13262 // Fall/slipping SFX for enemies
13263 // Fall SFX for items/weapons
13264 // Weapons/Misc sprite shared for falling items/weapons
13265 //Maybe slip SFX for Hero?
13266 // Weapons/Misc sprite override for falling sprite?
13267 //Update std.zh with relevant new stuff
13268
2/2
✓ Branch 0 taken 1033888 times.
✓ Branch 1 taken 26133228 times.
27167116 if(can_pitfall(ignore_hover))
13269 {
13270
2/2
✓ Branch 0 taken 2635028 times.
✓ Branch 1 taken 23498200 times.
26133228 bool can_diag = (diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK));
13271 26133228 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13272 26133228 int32_t ispitbl = getpitfall(x,y+15);
13273 26133228 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13274 26133228 int32_t ispitbr = getpitfall(x+15,y+15);
13275 26133228 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13276 26133228 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13277 26133228 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13278 26133228 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13279 26133228 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13280 26133228 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13281 26133228 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13282 26133228 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13283 static const int32_t flag_pit_irresistable = (1<<24);
13284
5/5
✓ Branch 0 taken 26125880 times.
✓ Branch 1 taken 1040 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 3220 times.
✓ Branch 4 taken 2979 times.
26133228 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13285 {
13286 1040 case 4: return -2; //Fully over pit; fall in
13287 case 3:
13288 {
13289
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
109 if(ispitul && ispitur && ispitbl) //UL_3
13290 {
13291
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13292 {
13293
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13294 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13295 }
13296 }
13297
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 else if(ispitul && ispitur && ispitbr) //UR_3
13298 {
13299 if(ispitur_50)
13300 {
13301 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13302 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13303 }
13304 }
13305
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
87 else if(ispitul && ispitbl && ispitbr) //BL_3
13306 {
13307
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(ispitbl_50)
13308 {
13309
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
9 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13310 9 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13311 }
13312 74 }
13313
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 else if(ispitbl && ispitur && ispitbr) //BR_3
13314 {
13315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ispitbr_50)
13316 {
13317
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13318 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13319 }
13320 }
13321 74 break;
13322 }
13323 case 2:
13324 {
13325
4/4
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 1860 times.
✓ Branch 2 taken 1351 times.
✓ Branch 3 taken 9 times.
3220 if(ispitul && ispitur) //Up
13326 {
13327
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(DrunkDown())
13328 {
13329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(ispitul_75 && ispitur_75) //Straight up
13330 {
13331 return up | flag_pit_irresistable | (ispitul << 8);
13332 }
13333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(ispitul_75)
13334 {
13335 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13336 }
13337
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(ispitur_75)
13338 {
13339 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13340 }
13341 3 else return -1;
13342 }
13343 else
13344 {
13345
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(ispitul_50 && ispitur_50) //Straight up
13346 {
13347 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13348 }
13349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(ispitul_50)
13350 {
13351 if(DrunkRight() && !ispitul_75) return -1;
13352 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13353 }
13354
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(ispitur_50)
13355 {
13356 if(DrunkLeft() && !ispitur_75) return -1;
13357 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13358 }
13359 }
13360 6 }
13361
4/4
✓ Branch 0 taken 1731 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1351 times.
✓ Branch 3 taken 380 times.
3211 else if(ispitbl && ispitbr) //Down
13362 {
13363
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 368 times.
380 if(DrunkUp())
13364 {
13365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13366 {
13367 return down | flag_pit_irresistable | (ispitbl << 8);
13368 }
13369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13370 {
13371 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13372 }
13373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13374 {
13375 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13376 }
13377 12 else return -1;
13378 }
13379 else
13380 {
13381
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
368 if(ispitbl_50 && ispitbr_50) //Straight down
13382 {
13383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13384 }
13385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 else if(ispitbl_50)
13386 {
13387 if(DrunkRight() && !ispitbl_75) return -1;
13388 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13389 }
13390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 else if(ispitbr_50)
13391 {
13392 if(DrunkLeft() && !ispitbr_75) return -1;
13393 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13394 }
13395 }
13396 362 }
13397
3/4
✓ Branch 0 taken 1351 times.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1351 times.
2831 else if(ispitbl && ispitul) //Left
13398 {
13399
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1191 times.
1351 if(DrunkRight())
13400 {
13401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if(ispitul_75 && ispitbl_75) //Straight left
13402 {
13403 return left | flag_pit_irresistable | (ispitul << 8);
13404 }
13405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 else if(ispitul_75)
13406 {
13407 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13408 }
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 else if(ispitbl_75)
13410 {
13411 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13412 }
13413 160 else return -1;
13414 }
13415 else
13416 {
13417
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1191 if(ispitul_50 && ispitbl_50) //Straight left
13418 {
13419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13420 }
13421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1170 times.
1170 else if(ispitul_50)
13422 {
13423 if(DrunkDown() && !ispitul_75) return -1;
13424 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13425 }
13426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1170 times.
1170 else if(ispitbl_50)
13427 {
13428 if(DrunkUp() && !ispitbl_75) return -1;
13429 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13430 }
13431 }
13432 1170 }
13433
2/4
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1480 times.
1480 else if(ispitbr && ispitur) //Right
13434 {
13435
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 1318 times.
1480 if(DrunkLeft())
13436 {
13437
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
162 if(ispitur_75 && ispitbr_75) //Straight right
13438 {
13439 6 return right | flag_pit_irresistable | (ispitur << 8);
13440 }
13441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 else if(ispitur_75)
13442 {
13443 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13444 }
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 else if(ispitbr_75)
13446 {
13447 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13448 }
13449 156 else return -1;
13450 }
13451 else
13452 {
13453
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
1318 if(ispitur_50 && ispitbr_50) //Straight right
13454 {
13455
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 20 times.
104 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13456 }
13457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
1214 else if(ispitur_50)
13458 {
13459 if(DrunkDown() && !ispitur_75) return -1;
13460 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13461 }
13462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
1214 else if(ispitbr_50)
13463 {
13464 if(DrunkUp() && !ispitbr_75) return -1;
13465 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13466 }
13467 }
13468 1214 }
13469 2752 break;
13470 }
13471 case 1:
13472 {
13473
3/4
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 2013 times.
✓ Branch 2 taken 966 times.
✗ Branch 3 not taken.
2979 if(ispitul && ispitul_50) //UL_1
13474 {
13475 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13476 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13477 }
13478
4/4
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 2471 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 35 times.
2979 if(ispitur && ispitur_50) //UR_1
13479 {
13480
4/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
35 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13481 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13482 }
13483
3/4
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2568 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
2944 if(ispitbl && ispitbl_50) //BL_1
13484 {
13485 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13486 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13487 }
13488
3/4
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 1815 times.
✓ Branch 2 taken 1129 times.
✗ Branch 3 not taken.
2944 if(ispitbr && ispitbr_50) //BR_1
13489 {
13490 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13491 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13492 }
13493 2944 break;
13494 }
13495 }
13496 26131650 }
13497 27165538 return -1;
13498 27167116 }
13499
13500 6074122 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13501 {
13502 6074122 pitfall();
13503
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6074118 times.
6074122 if(fallclk) return true;
13504 6074118 int32_t val = check_pitslide();
13505 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13506
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6074097 times.
6074118 if(val == -1)
13507 {
13508 6074097 pit_pulldir = -1;
13509 6074097 pit_pullclk = 0;
13510 6074097 return false;
13511 }
13512 21 int32_t dir = val&0xFF;
13513 21 int32_t cmbid = (val&0xFFFF00)>>8;
13514 21 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13516 {
13517 pit_pulldir = -1;
13518 pit_pullclk = 0;
13519 return false;
13520 }
13521
4/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 2 times.
21 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13522 {
13523 2 pit_pulldir = -1;
13524 2 pit_pullclk = 0;
13525 2 return false;
13526 }
13527 19 pit_pulldir = dir;
13528 19 int32_t step = 1;
13529
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4 times.
19 if(sensitivity == 0)
13530 {
13531 4 step = 2;
13532 4 sensitivity = 1;
13533 4 }
13534
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10 times.
19 if(pit_pullclk++ % sensitivity) //No pull this frame
13535 9 return (val&0x100);
13536
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 10 times.
23 for(; step > 0 && !fallclk; --step)
13537 {
13538
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1 times.
13 switch(dir)
13539 {
13540 case l_up: case l_down: case left:
13541 --x; break;
13542 case r_up: case r_down: case right:
13543 12 ++x; break;
13544 }
13545
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12 times.
13 switch(dir)
13546 {
13547 case l_up: case r_up: case up:
13548 --y; break;
13549 case l_down: case r_down: case down:
13550 1 ++y; break;
13551 }
13552 13 pitfall();
13553 13 }
13554
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 return fallclk || (val&0x100);
13555 6074122 }
13556
13557 6074625 void HeroClass::pitfall()
13558 {
13559
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 6074135 times.
6074625 if(fallclk)
13560 {
13561 490 drop_liftwpn();
13562
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
490 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13563 //Handle falling
13564
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 7 times.
490 if(!--fallclk)
13565 {
13566 7 std::vector<int32_t> &ev = FFCore.eventData;
13567 7 ev.clear();
13568 7 ev.push_back(fallCombo*10000);
13569
13570 7 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
13571
13572 7 fallCombo = ev[0]/10000;
13573
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
13574 fallCombo = 0;
13575
13576 7 int32_t dmg = game->get_hp_per_heart()/4;
13577 7 bool dmg_perc = false;
13578 7 bool warp = false;
13579
13580 7 action=none; FFCore.setHeroAction(none);
13581
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(cmb)
13583 {
13584 7 dmg = cmb->attributes[0]/10000L;
13585 7 dmg_perc = cmb->usrflags&cflag3;
13586 7 warp = cmb->usrflags&cflag1;
13587 7 }
13588
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(cheat_superman && dmg > 0)
13589 dmg = 0;
13590
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(dmg) //Damage
13591 {
13592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13594 3 }
13595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(warp) //Warp
13596 {
13597 sdir = dir;
13598 if(cmb->usrflags&cflag2) //Direct Warp
13599 {
13600 didpit=true;
13601 pitx=x;
13602 pity=y;
13603 }
13604 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13605 }
13606 else //Reset to screen entry
13607 {
13608 7 go_respawn_point();
13609 }
13610 7 }
13611 490 }
13612
2/2
✓ Branch 0 taken 324963 times.
✓ Branch 1 taken 5749172 times.
6074135 else if(can_pitfall())
13613 {
13614 5749172 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13615 5749172 bool ispitbl = ispitfall(x,y+15);
13616 5749172 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13617 5749172 bool ispitbr = ispitfall(x+15,y+15);
13618 5749172 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13619
9/10
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 5748672 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 268 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
5749172 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13620 {
13621
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13622
3/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4 times.
7 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13623 7 fallclk = PITFALL_FALL_FRAMES;
13624 7 fallCombo = pitctr;
13625 7 action=falling; FFCore.setHeroAction(falling);
13626 7 spins = 0;
13627 7 charging = 0;
13628 7 drop_liftwpn();
13629 7 }
13630 5749172 }
13631 6074625 }
13632
13633 void HeroClass::mod_steps(std::vector<zfix*>& v)
13634 {
13635 bool can_combo = ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS);
13636 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
13637 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
13638 //!DIMITODO: add QR for slow combos under hero
13639 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
13640 {
13641 if(tmpscr2[i].valid!=0)
13642 {
13643 if (get_qr(qr_OLD_BRIDGE_COMBOS))
13644 {
13645 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13646 {
13647 slowcombo = false;
13648 break;
13649 }
13650 }
13651 else
13652 {
13653 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
13654 {
13655 slowcombo = false;
13656 break;
13657 }
13658 }
13659 }
13660 }
13661 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
13662 bool is_swimming = (action == swimming);
13663 int32_t shieldid = getCurrentActiveShield();
13664 if(shieldid > -1)
13665 {
13666 itemdata const& shield = itemsbuf[shieldid];
13667 if(shield.flags & ITEM_FLAG10) //Change Speed flag
13668 {
13669 zfix perc = shield.misc7;
13670 perc /= 100;
13671 if(perc < 0)
13672 perc = (perc*-1)+1;
13673 zfix add(shield.misc8);
13674 add /= 100;
13675 for(zfix* stp : v)
13676 {
13677 zfix& pix = *stp;
13678 pix = (pix * perc) + add;
13679 }
13680 }
13681 }
13682
13683 auto slow_cpos = COMBOPOS(x+7,y+8);
13684 if(can_combo) for(int q = 6; q >= 0; --q)
13685 {
13686 mapscr* m = FFCore.tempScreens[q];
13687 if(!m->valid) continue;
13688 newcombo const& cmb = combobuf[m->data[slow_cpos]];
13689
13690 if (cmb.speed_mult != 1 || cmb.speed_div || cmb.speed_add)
13691 {
13692 for(zfix* stp : v)
13693 {
13694 zfix& pix = *stp;
13695 pix *= cmb.speed_mult;
13696 if(cmb.speed_div)
13697 pix /= cmb.speed_div;
13698 pix += cmb.speed_add;
13699 }
13700 }
13701 if(q > 0 && cmb.type == cBRIDGE)
13702 {
13703 if(get_qr(qr_OLD_BRIDGE_COMBOS)
13704 ? !_walkflag_layer(x+7,y+8,1,&(tmpscr2[q-1]))
13705 : _effectflag_layer(x+7,y+8,1,&(tmpscr2[q-1])))
13706 {
13707 break; //Bridge blocks speed change from below it
13708 }
13709 }
13710 }
13711 zfix mult = 1, div = 1;
13712 if(is_swimming)
13713 {
13714 mult = game->swim_mult;
13715 div = game->swim_div;
13716 }
13717 else if(slowcharging && slowcombo) //1/2 speed
13718 {
13719 div = 2;
13720 }
13721 else if(slowcharging || slowcombo) //2/3 speed
13722 {
13723 mult = 2;
13724 div = 3;
13725 }
13726 if(!div) div = 1;
13727 if(mult != 1 || div != 1)
13728 {
13729 for(zfix* stp : v)
13730 {
13731 zfix& pix = *stp;
13732 pix = ((pix / div) * mult);
13733 }
13734 }
13735 }
13736
13737 6960981 void HeroClass::moveheroOld()
13738 {
13739
2/4
✓ Branch 0 taken 6960981 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6960981 times.
6960981 if(lstunclock || is_conveyor_stunned) return;
13740 6960981 int32_t xoff=x.getInt()&7;
13741 6960981 int32_t yoff=y.getInt()&7;
13742
3/4
✓ Branch 0 taken 6937014 times.
✓ Branch 1 taken 23967 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6937014 times.
6960981 if(NO_GRIDLOCK)
13743 {
13744 23967 xoff = 0;
13745 23967 yoff = 0;
13746 23967 }
13747 6960981 int32_t push=pushing;
13748 6960981 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13749 6960981 pushing=0;
13750 6960981 zfix temp_step(hero_newstep);
13751 6960981 zfix temp_x(x);
13752 6960981 zfix temp_y(y);
13753
13754 6960981 int32_t flippers_id = current_item_id(itype_flippers);
13755 6960981 itemdata const& itm = itemsbuf[flippers_id];
13756 6960981 byte intbtn = byte(itm.misc3&0xFF);
13757 6960981 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
13758 6960981 bool eatdive = false;
13759
2/2
✓ Branch 0 taken 6039 times.
✓ Branch 1 taken 6954942 times.
6960981 if(diveclk>0)
13760 {
13761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6039 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6039 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
13762 6039 --diveclk;
13763
4/8
✓ Branch 0 taken 4022 times.
✓ Branch 1 taken 2017 times.
✓ Branch 2 taken 4022 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4022 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6039 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
13764 {
13765 diveclk = itemsbuf[flippers_id].misc2;
13766 eatdive = true;
13767 }
13768 6039 }
13769
4/4
✓ Branch 0 taken 60735 times.
✓ Branch 1 taken 6894207 times.
✓ Branch 2 taken 60638 times.
✓ Branch 3 taken 97 times.
6954942 else if(action == swimming && dive_pressed)
13770 {
13771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13772 97 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13773
13774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(global_diving==screen_diving)
13775 {
13776
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13777 97 eatdive = true;
13778 97 }
13779 97 }
13780
2/2
✓ Branch 0 taken 6960884 times.
✓ Branch 1 taken 97 times.
6960981 if(eatdive)
13781 97 getIntBtnInput(intbtn, true, true, false, false, false);
13782
13783
2/2
✓ Branch 0 taken 6892024 times.
✓ Branch 1 taken 68957 times.
6960981 if(action==rafting)
13784 {
13785 68957 do_rafting();
13786
13787
2/2
✓ Branch 0 taken 68774 times.
✓ Branch 1 taken 183 times.
68957 if(action==rafting)
13788 {
13789 68774 return;
13790 }
13791
13792
13793 183 set_respawn_point();
13794 183 trySideviewLadder();
13795 183 }
13796
13797 6892207 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13798 6892207 int32_t btnwpn = -1;
13799
13800 //&0xFFF removes the "bow & arrows" bitmask
13801 //The Quick Sword is allowed to interrupt attacks.
13802
4/4
✓ Branch 0 taken 6787542 times.
✓ Branch 1 taken 104665 times.
✓ Branch 2 taken 3988837 times.
✓ Branch 3 taken 2798705 times.
6892207 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13803
8/8
✓ Branch 0 taken 6070147 times.
✓ Branch 1 taken 822060 times.
✓ Branch 2 taken 6063762 times.
✓ Branch 3 taken 6385 times.
✓ Branch 4 taken 230943 times.
✓ Branch 5 taken 597502 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 795183 times.
6892207 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13804 {
13805
2/2
✓ Branch 0 taken 17018 times.
✓ Branch 1 taken 6080006 times.
6097024 if(DrunkrBbtn())
13806 {
13807 17018 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13808 17018 dowpn = Bwpn&0xFFF;
13809 17018 directWpn = directItemB;
13810 17018 }
13811
2/2
✓ Branch 0 taken 47079 times.
✓ Branch 1 taken 6032927 times.
6080006 else if(DrunkrAbtn())
13812 {
13813 47079 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13814 47079 dowpn = Awpn&0xFFF;
13815 47079 directWpn = directItemA;
13816 47079 }
13817
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 5961258 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
6032927 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13818 {
13819 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13820 7 dowpn = Xwpn&0xFFF;
13821 7 directWpn = directItemX;
13822 7 }
13823
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 5961258 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
6032920 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13824 {
13825 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13826 105 dowpn = Ywpn&0xFFF;
13827 105 directWpn = directItemY;
13828 105 }
13829
13830
1/2
✓ Branch 0 taken 6097024 times.
✗ Branch 1 not taken.
6097024 if(directWpn > 255) directWpn = 0;
13831
13832 // The Quick Sword only allows repeated sword or wand swings.
13833
7/8
✓ Branch 0 taken 6063762 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 6063762 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6064275 times.
6097024 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13834 32749 btnwpn=-1;
13835 6097024 }
13836
13837
2/2
✓ Branch 0 taken 318579 times.
✓ Branch 1 taken 6573628 times.
6892207 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13838
11/12
✓ Branch 0 taken 6466229 times.
✓ Branch 1 taken 425978 times.
✓ Branch 2 taken 6010648 times.
✓ Branch 3 taken 455581 times.
✓ Branch 4 taken 5935157 times.
✓ Branch 5 taken 75491 times.
✓ Branch 6 taken 5879772 times.
✓ Branch 7 taken 55385 times.
✓ Branch 8 taken 44001 times.
✓ Branch 9 taken 5835771 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 44001 times.
6892207 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13839 {
13840
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 42435 times.
44001 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13841
5/6
✓ Branch 0 taken 43999 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 43984 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
44001 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13842 {
13843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43984 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43984 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13844 {
13845 paymagiccost(attackid,true);
13846 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13847 }
13848 43984 SetAttack();
13849 43984 attack=wSword;
13850
13851 43984 attackclk=0;
13852
2/2
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 1551 times.
43984 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13853
13854
2/10
✓ Branch 0 taken 43984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43984 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
43984 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13855 {
13856 if(!checkmagiccost(dowpn))
13857 {
13858 item_error();
13859 }
13860 else
13861 {
13862 //clear the item script stack for a new script
13863 int i = dowpn;
13864 FFCore.reset_script_engine_data(ScriptType::Item, i);
13865 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13866 did_scripta=true;
13867 }
13868 }
13869 43984 }
13870 else
13871 {
13872 17 item_error();
13873 }
13874 44001 }
13875 else
13876 {
13877 6848206 did_scripta=false;
13878 }
13879
13880
6/10
✓ Branch 0 taken 6826022 times.
✓ Branch 1 taken 66185 times.
✓ Branch 2 taken 6826022 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6826022 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6826022 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6826022 times.
6892207 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13881 {
13882
3/4
✓ Branch 0 taken 1134509 times.
✓ Branch 1 taken 5691513 times.
✓ Branch 2 taken 1134509 times.
✗ Branch 3 not taken.
6826022 if(DrunkUp() && canSideviewLadder())
13883 {
13884 setOnSideviewLadder(true);
13885 }
13886
3/4
✓ Branch 0 taken 949175 times.
✓ Branch 1 taken 5876847 times.
✓ Branch 2 taken 949175 times.
✗ Branch 3 not taken.
6826022 else if(DrunkDown() && canSideviewLadder(true))
13887 {
13888 y+=1;
13889 setOnSideviewLadder(true);
13890 }
13891 6826022 }
13892
13893 6892207 int32_t wx=x;
13894 6892207 int32_t wy=y;
13895
3/6
✓ Branch 0 taken 4619211 times.
✓ Branch 1 taken 2272996 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6892207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6892207 if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13896 {
13897 if((xoff==0)||diagonalMovement)
13898 {
13899 if(DrunkUp()) dir=up;
13900 if(DrunkDown()) dir=down;
13901 }
13902
13903 if((yoff==0)||diagonalMovement)
13904 {
13905 if(DrunkLeft()) dir=left;
13906 if(DrunkRight()) dir=right;
13907 }
13908 }
13909
13910
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1607765 times.
✓ Branch 2 taken 1344903 times.
✓ Branch 3 taken 1884156 times.
✓ Branch 4 taken 2055383 times.
6892207 switch(dir)
13911 {
13912 case up:
13913 1607765 wy-=16;
13914 1607765 break;
13915
13916 case down:
13917 1344903 wy+=16;
13918 1344903 break;
13919
13920 case left:
13921 1884156 wx-=16;
13922 1884156 break;
13923
13924 case right:
13925 2055383 wx+=16;
13926 2055383 break;
13927 }
13928
13929 6892207 do_lens();
13930
13931 6892207 WalkflagInfo info;
13932
13933 6892207 bool no_jinx = true;
13934
7/8
✓ Branch 0 taken 6466229 times.
✓ Branch 1 taken 425978 times.
✓ Branch 2 taken 19532 times.
✓ Branch 3 taken 6446697 times.
✓ Branch 4 taken 19532 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1101 times.
✓ Branch 7 taken 18431 times.
6892207 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13935 {
13936 18431 bool paidmagic = false;
13937
1/2
✓ Branch 0 taken 18431 times.
✗ Branch 1 not taken.
18431 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
13938
7/10
✓ Branch 0 taken 18431 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16895 times.
✓ Branch 3 taken 1536 times.
✓ Branch 4 taken 489 times.
✓ Branch 5 taken 1047 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 489 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1536 times.
18431 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13939 {
13940
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 1047 times.
1536 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13941 1536 no_jinx = checkitem_jinx(attackid);
13942
3/8
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1536 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1536 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13943 {
13944
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1536 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13945 paymagiccost(attackid,true);
13946 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13947 }
13948 1536 SetAttack();
13949 1536 attack=wWand;
13950 1536 attackclk=0;
13951 1536 }
13952 else
13953 {
13954 item_error();
13955 }
13956 1536 }
13957
5/8
✓ Branch 0 taken 16895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 16130 times.
✓ Branch 4 taken 765 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 765 times.
17660 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13958
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 765 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 763 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
765 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13959 {
13960 765 no_jinx = checkitem_jinx(dowpn);
13961
3/6
✓ Branch 0 taken 765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 765 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 765 times.
765 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13962 {
13963 item_error();
13964 }
13965 else
13966 {
13967 765 paymagiccost(dowpn);
13968 765 paidmagic = true;
13969 765 SetAttack();
13970 765 attack=wHammer;
13971
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 763 times.
765 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13972 765 attackclk=0;
13973 }
13974 765 }
13975
5/8
✓ Branch 0 taken 16130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1208 times.
✓ Branch 3 taken 14922 times.
✓ Branch 4 taken 1208 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1208 times.
17338 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13976
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
✓ Branch 2 taken 1034 times.
✓ Branch 3 taken 174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 174 times.
1208 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13977 {
13978 //checkbunny handled where magic cost is paid
13979
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1034 times.
1208 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13980 1208 no_jinx = checkitem_jinx(attackid);
13981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 if(no_jinx)
13982 {
13983 1208 SetAttack();
13984 1208 attack=wFire;
13985 1208 attackclk=0;
13986 1208 }
13987 1208 }
13988
5/8
✓ Branch 0 taken 14922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 14918 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
14926 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13989
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13990 {
13991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13992 4 no_jinx = checkitem_jinx(attackid);
13993
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13994 {
13995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13996 paymagiccost(attackid,true);
13997 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13998 }
13999 4 SetAttack();
14000 4 attack=wCByrna;
14001 4 attackclk=0;
14002 4 }
14003 else
14004 {
14005 item_error();
14006 }
14007 4 }
14008
2/8
✓ Branch 0 taken 14918 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14918 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14918 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
14009 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
14010 {
14011 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
14012 no_jinx = checkitem_jinx(attackid);
14013 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
14014 {
14015 paymagiccost(attackid);
14016 SetAttack();
14017 attack = wBugNet;
14018 attackclk = 0;
14019 sfx(itemsbuf[attackid].usesound);
14020 }
14021 else
14022 {
14023 item_error();
14024 }
14025 }
14026 else
14027 {
14028
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 14841 times.
14918 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14029 14918 no_jinx = checkitem_jinx(itmid);
14030
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14904 times.
14918 if(no_jinx)
14031 {
14032 14904 paidmagic = startwpn(itmid);
14033
14034
2/2
✓ Branch 0 taken 11478 times.
✓ Branch 1 taken 3426 times.
14904 if(paidmagic)
14035 {
14036
5/10
✓ Branch 0 taken 11478 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11478 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11478 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11478 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 11478 times.
11478 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
14037 {
14038 ;
14039 }
14040 else
14041 {
14042 11478 SetAttack();
14043 11478 attackclk=0;
14044 11478 attack=none;
14045
14046
2/2
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 9573 times.
11478 if(btnwpn==itype_brang)
14047 {
14048 9573 attack=wBrang;
14049 9573 }
14050 }
14051 11478 }
14052 else
14053 {
14054 // Weapon not started: directWpn should be reset to prev. value.
14055 3426 directWpn = olddirectwpn;
14056 }
14057 14904 }
14058 }
14059
14060
8/12
✓ Branch 0 taken 18431 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18417 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 17551 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18431 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14061 {
14062
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800 times.
800 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
14063 {
14064 item_error();
14065 }
14066 else
14067 {
14068 // Only charge for magic if item's magic cost wasn't already charged
14069 // for the item's main use.
14070
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 795 times.
800 if(!paidmagic && attack!=wWand)
14071 795 paymagiccost(dowpn);
14072 //clear the item script stack for a new script
14073 800 int i = dowpn;
14074 800 FFCore.reset_script_engine_data(ScriptType::Item, i);
14075 800 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14076 800 did_scriptb=true;
14077 }
14078 800 }
14079
14080
7/12
✓ Branch 0 taken 18417 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 18417 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18417 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18417 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18417 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 18417 times.
18431 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
14081 {
14082 return;
14083 }
14084
2/2
✓ Branch 0 taken 18417 times.
✓ Branch 1 taken 14 times.
18431 if(!no_jinx)
14085 14 did_scriptb = false;
14086 18431 }
14087 else
14088 {
14089 6873776 did_scriptb=false;
14090 }
14091
14092
5/6
✓ Branch 0 taken 6070659 times.
✓ Branch 1 taken 821548 times.
✓ Branch 2 taken 6005298 times.
✓ Branch 3 taken 65361 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6005298 times.
6892207 if(attackclk || action==attacking || action==sideswimattacking)
14093 {
14094
14095
4/8
✓ Branch 0 taken 65361 times.
✓ Branch 1 taken 821548 times.
✓ Branch 2 taken 65361 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 65361 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
886909 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14096 {
14097 if((xoff==0)||diagonalMovement)
14098 {
14099 if(DrunkUp()) dir=up;
14100 if(DrunkDown()) dir=down;
14101 }
14102
14103 if((yoff==0)||diagonalMovement)
14104 {
14105 if(DrunkLeft()) dir=left;
14106 if(DrunkRight()) dir=right;
14107 }
14108 }
14109
14110 886909 bool attacked = doattack();
14111
14112 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14113
10/12
✓ Branch 0 taken 885116 times.
✓ Branch 1 taken 1793 times.
✓ Branch 2 taken 626136 times.
✓ Branch 3 taken 258980 times.
✓ Branch 4 taken 120168 times.
✓ Branch 5 taken 505968 times.
✓ Branch 6 taken 118492 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 118492 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 118492 times.
886909 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14114 {
14115
4/4
✓ Branch 0 taken 50659 times.
✓ Branch 1 taken 67833 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 45951 times.
118492 if((xoff==0)||diagonalMovement)
14116 {
14117
2/2
✓ Branch 0 taken 64793 times.
✓ Branch 1 taken 7748 times.
72541 if(DrunkUp()) dir=up;
14118
14119
2/2
✓ Branch 0 taken 64520 times.
✓ Branch 1 taken 8021 times.
72541 if(DrunkDown()) dir=down;
14120 72541 }
14121
14122
4/4
✓ Branch 0 taken 37988 times.
✓ Branch 1 taken 80504 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 34706 times.
118492 if((yoff==0)||diagonalMovement)
14123 {
14124
2/2
✓ Branch 0 taken 73248 times.
✓ Branch 1 taken 10538 times.
83786 if(DrunkLeft()) dir=left;
14125
14126
2/2
✓ Branch 0 taken 73306 times.
✓ Branch 1 taken 10480 times.
83786 if(DrunkRight()) dir=right;
14127 83786 }
14128 118492 }
14129
14130
9/10
✓ Branch 0 taken 824408 times.
✓ Branch 1 taken 62501 times.
✓ Branch 2 taken 822487 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 822052 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 817837 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 817837 times.
886909 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14131 {
14132 817837 return;
14133 }
14134
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 62501 times.
69072 else if(!attacked)
14135 {
14136 // Spin attack - change direction
14137
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 62253 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
62501 if(spins>1 && attack != wHammer)
14138 {
14139 248 spins--;
14140
14141
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
14142 {
14143
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
14144 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
14145 45 }
14146 248 attackclk=1;
14147
14148
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
14149 {
14150 case up:
14151 62 dir=left;
14152 62 break;
14153
14154 case right:
14155 62 dir=up;
14156 62 break;
14157
14158 case down:
14159 62 dir=right;
14160 62 break;
14161
14162 case left:
14163 62 dir=down;
14164 62 break;
14165 }
14166
14167 248 return;
14168 }
14169 else
14170 {
14171 62253 spins=0;
14172 }
14173
14174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62253 times.
62253 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
14175 62253 else {action=none; FFCore.setHeroAction(none);}
14176 62253 attackclk=0;
14177 62253 charging=0;
14178 62253 }
14179 68824 }
14180
14181
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6074115 times.
6074122 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
14182 7 return;
14183
14184
2/2
✓ Branch 0 taken 2399587 times.
✓ Branch 1 taken 3674528 times.
6074115 if(action==walking) //still walking
14185 {
14186
9/10
✓ Branch 0 taken 2760624 times.
✓ Branch 1 taken 913904 times.
✓ Branch 2 taken 2017023 times.
✓ Branch 3 taken 743601 times.
✓ Branch 4 taken 1070833 times.
✓ Branch 5 taken 946190 times.
✓ Branch 6 taken 45962 times.
✓ Branch 7 taken 1024871 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 45962 times.
3674528 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
14187 {
14188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45962 times.
45962 if(attackclk>0) SetAttack();
14189 45962 else {action = none; FFCore.setHeroAction(none);}
14190 45962 hero_count=-1;
14191 45962 return;
14192 }
14193
14194 3628566 autostep=false;
14195
14196
4/6
✓ Branch 0 taken 3182222 times.
✓ Branch 1 taken 446344 times.
✓ Branch 2 taken 3182222 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3182222 times.
3628566 if(!(diagonalMovement || NO_GRIDLOCK))
14197 {
14198
2/4
✓ Branch 0 taken 3182222 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3182222 times.
3182222 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
14199 {
14200 if(dir==up&&yoff)
14201 {
14202 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
14203 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
14204 execute(info);
14205
14206 if(!info.isUnwalkable())
14207 {
14208 moveOld2(up);
14209 }
14210 else
14211 {
14212 action=none; FFCore.setHeroAction(none);
14213 }
14214
14215 return;
14216 }
14217
14218 if(dir==down&&yoff)
14219 {
14220 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
14221 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
14222 execute(info);
14223
14224 if(!info.isUnwalkable())
14225 {
14226 moveOld2(down);
14227 }
14228 else
14229 {
14230 action=none; FFCore.setHeroAction(none);
14231 }
14232
14233 return;
14234 }
14235
14236 if(dir==left&&xoff)
14237 {
14238 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
14239 execute(info);
14240
14241 if(!info.isUnwalkable())
14242 {
14243 moveOld2(left);
14244 }
14245 else
14246 {
14247 action=none; FFCore.setHeroAction(none);
14248 }
14249
14250 return;
14251 }
14252
14253 if(dir==right&&xoff)
14254 {
14255 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
14256 execute(info);
14257
14258 if(!info.isUnwalkable())
14259 {
14260 moveOld2(right);
14261 }
14262 else
14263 {
14264 action=none; FFCore.setHeroAction(none);
14265 }
14266
14267 return;
14268 }
14269 }
14270 else
14271 {
14272
4/4
✓ Branch 0 taken 743251 times.
✓ Branch 1 taken 2438971 times.
✓ Branch 2 taken 121901 times.
✓ Branch 3 taken 621350 times.
3182222 if(dir==up&&yoff)
14273 {
14274 621350 while(true)
14275 {
14276 621352 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
14277 621352 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
14278 621352 execute(info);
14279
14280
2/2
✓ Branch 0 taken 2705 times.
✓ Branch 1 taken 618647 times.
621352 if(!info.isUnwalkable())
14281 {
14282 618647 hero_newstep = temp_step;
14283 618647 x = temp_x;
14284 618647 y = temp_y;
14285 618647 moveOld2(up);
14286 618647 return;
14287 }
14288 //Could not move, try moving less
14289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2705 times.
2705 if(temp_y != int32_t(temp_y))
14290 {
14291 temp_y = floor((double)temp_y);
14292 continue;
14293 }
14294
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2703 times.
2705 else if(temp_step > 1)
14295 {
14296
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_step != int32_t(temp_step)) //floor
14297 2 temp_step = floor((double)temp_step);
14298 else --temp_step;
14299 2 continue;
14300 }
14301 else //Can't move less, stop moving
14302 {
14303 2703 action=none; FFCore.setHeroAction(none);
14304 }
14305 2703 return;
14306 }
14307 }
14308
14309
4/4
✓ Branch 0 taken 607367 times.
✓ Branch 1 taken 1953505 times.
✓ Branch 2 taken 100455 times.
✓ Branch 3 taken 506912 times.
2560872 if(dir==down&&yoff)
14310 {
14311 506912 while(true)
14312 {
14313 506946 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14314 506946 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14315 506946 execute(info);
14316
14317
2/2
✓ Branch 0 taken 2589 times.
✓ Branch 1 taken 504357 times.
506946 if(!info.isUnwalkable())
14318 {
14319 504357 hero_newstep = temp_step;
14320 504357 x = temp_x;
14321 504357 y = temp_y;
14322 504357 moveOld2(down);
14323 504357 return;
14324 }
14325 //Could not move, try moving less
14326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2589 times.
2589 if(temp_y != int32_t(temp_y))
14327 {
14328 temp_y = floor((double)temp_y);
14329 continue;
14330 }
14331
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2555 times.
2589 else if(temp_step > 1)
14332 {
14333
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(temp_step != int32_t(temp_step)) //floor
14334 34 temp_step = floor((double)temp_step);
14335 else --temp_step;
14336 34 continue;
14337 }
14338 else //Can't move less, stop moving
14339 {
14340 2555 action=none; FFCore.setHeroAction(none);
14341 }
14342 2555 return;
14343 }
14344 }
14345
14346
4/4
✓ Branch 0 taken 887392 times.
✓ Branch 1 taken 1166568 times.
✓ Branch 2 taken 148829 times.
✓ Branch 3 taken 738563 times.
2053960 if(dir==left&&xoff)
14347 {
14348 738563 while(true)
14349 {
14350 738563 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14351 738563 execute(info);
14352
14353
2/2
✓ Branch 0 taken 2723 times.
✓ Branch 1 taken 735840 times.
738563 if(!info.isUnwalkable())
14354 {
14355 735840 hero_newstep = temp_step;
14356 735840 x = temp_x;
14357 735840 y = temp_y;
14358 735840 moveOld2(left);
14359 735840 return;
14360 }
14361 //Could not move, try moving less
14362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2723 times.
2723 if(temp_x != int32_t(temp_x))
14363 {
14364 temp_x = floor((double)temp_x);
14365 continue;
14366 }
14367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2723 times.
2723 else if(temp_step > 1)
14368 {
14369 if(temp_step != int32_t(temp_step)) //floor
14370 temp_step = floor((double)temp_step);
14371 else --temp_step;
14372 continue;
14373 }
14374 else //Can't move less, stop moving
14375 {
14376 2723 action=none; FFCore.setHeroAction(none);
14377 }
14378 2723 return;
14379 }
14380 }
14381
14382
4/4
✓ Branch 0 taken 944212 times.
✓ Branch 1 taken 371185 times.
✓ Branch 2 taken 158117 times.
✓ Branch 3 taken 786095 times.
1315397 if(dir==right&&xoff)
14383 {
14384 786095 while(true)
14385 {
14386 786143 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
14387 786143 execute(info);
14388
14389
2/2
✓ Branch 0 taken 2962 times.
✓ Branch 1 taken 783181 times.
786143 if(!info.isUnwalkable())
14390 {
14391 783181 hero_newstep = temp_step;
14392 783181 x = temp_x;
14393 783181 y = temp_y;
14394 783181 moveOld2(right);
14395 783181 return;
14396 }
14397 //Could not move, try moving less
14398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2962 times.
2962 if(temp_x != int32_t(temp_x))
14399 {
14400 temp_x = floor((double)temp_x);
14401 continue;
14402 }
14403
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 2914 times.
2962 else if(temp_step > 1)
14404 {
14405
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(temp_step != int32_t(temp_step)) //floor
14406 48 temp_step = floor((double)temp_step);
14407 else --temp_step;
14408 48 continue;
14409 }
14410 else //Can't move less, stop moving
14411 {
14412 2914 action=none; FFCore.setHeroAction(none);
14413 }
14414 2914 return;
14415 }
14416 }
14417 }
14418 529302 }
14419
14420 975646 } // endif (action==walking)
14421
14422
16/24
✓ Branch 0 taken 3309048 times.
✓ Branch 1 taken 66185 times.
✓ Branch 2 taken 3309048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3309048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3309048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3309048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3309048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3309048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3309048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3309048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 3307127 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 3306692 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 74868 times.
✓ Branch 23 taken 3231824 times.
3375233 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14423 {
14424 3231824 action=none; FFCore.setHeroAction(none);
14425 3231824 }
14426
14427
2/2
✓ Branch 0 taken 852609 times.
✓ Branch 1 taken 2522624 times.
3375233 if(diagonalMovement)
14428 {
14429
5/5
✓ Branch 0 taken 302301 times.
✓ Branch 1 taken 91613 times.
✓ Branch 2 taken 70259 times.
✓ Branch 3 taken 178769 times.
✓ Branch 4 taken 209667 times.
852609 switch(holddir)
14430 {
14431 case up:
14432
2/2
✓ Branch 0 taken 88404 times.
✓ Branch 1 taken 3209 times.
91613 if(!Up())
14433 {
14434 3209 holddir=-1;
14435 3209 }
14436
14437 91613 break;
14438
14439 case down:
14440
2/2
✓ Branch 0 taken 67448 times.
✓ Branch 1 taken 2811 times.
70259 if(!Down())
14441 {
14442 2811 holddir=-1;
14443 2811 }
14444
14445 70259 break;
14446
14447 case left:
14448
2/2
✓ Branch 0 taken 173216 times.
✓ Branch 1 taken 5553 times.
178769 if(!Left())
14449 {
14450 5553 holddir=-1;
14451 5553 }
14452
14453 178769 break;
14454
14455 case right:
14456
2/2
✓ Branch 0 taken 203616 times.
✓ Branch 1 taken 6051 times.
209667 if(!Right())
14457 {
14458 6051 holddir=-1;
14459 6051 }
14460
14461 209667 break;
14462
14463 default:
14464 302301 break;
14465 } //end switch
14466
14467
3/4
✓ Branch 0 taken 714439 times.
✓ Branch 1 taken 138170 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 714439 times.
852609 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14468 {
14469 138170 walkable = false;
14470
6/6
✓ Branch 0 taken 24701 times.
✓ Branch 1 taken 113469 times.
✓ Branch 2 taken 23923 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 6343 times.
✓ Branch 5 taken 17580 times.
138170 if(DrunkUp()&&(holddir==-1||holddir==up))
14471 {
14472
4/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 18272 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18358 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
14473 {
14474 }
14475 else
14476 {
14477
4/10
✓ Branch 0 taken 18358 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18358 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18358 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 18358 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18358 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
14478 {
14479 18358 dir=up;
14480 18358 }
14481
14482 18358 holddir=up;
14483
14484
3/4
✓ Branch 0 taken 2134 times.
✓ Branch 1 taken 16224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2134 times.
18358 if(DrunkRight()&&shiftdir!=left)
14485 {
14486 2134 shiftdir=right;
14487
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2134 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2134 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14489 2134 }
14490
4/4
✓ Branch 0 taken 2385 times.
✓ Branch 1 taken 13839 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 2382 times.
16224 else if(DrunkLeft()&&shiftdir!=right)
14491 {
14492 2382 shiftdir=left;
14493
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2382 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2382 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14495 2382 }
14496 else
14497 {
14498 13842 shiftdir=-1;
14499 }
14500
14501 //walkable if Ladder can be placed or is already placed vertically
14502
1/20
✗ Branch 0 not taken.
✓ Branch 1 taken 18358 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
18358 if(isSideViewHero() && !toogam && (!get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14503 {
14504 walkable=false;
14505 }
14506 else
14507 {
14508 18358 do
14509 {
14510 20944 zfix ty = y - hero_newstep;
14511 41888 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14512 20944 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14513
14514
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 20893 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
20944 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14515 {
14516 51 info = info || walkflag(x, zfix(0), 2, up);
14517 51 info = info || walkflag(x+15, zfix(0), 1, up);
14518 51 }
14519 20944 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14520
14521 20944 execute(info);
14522
14523
2/2
✓ Branch 0 taken 4970 times.
✓ Branch 1 taken 15974 times.
20944 if(info.isUnwalkable())
14524 {
14525
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 4768 times.
4970 if(y != y.getInt())
14526 {
14527 202 y.doRound();
14528 202 }
14529
2/2
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 2384 times.
4768 else if(hero_newstep > 1)
14530 {
14531
1/2
✓ Branch 0 taken 2384 times.
✗ Branch 1 not taken.
2384 if(hero_newstep != int32_t(hero_newstep)) //floor
14532 2384 hero_newstep = floor((double)hero_newstep);
14533 else --hero_newstep;
14534 2384 }
14535 else
14536 2384 break;
14537 2586 }
14538 15974 else walkable = true;
14539
2/2
✓ Branch 0 taken 2586 times.
✓ Branch 1 taken 15974 times.
18560 }
14540 18560 while(!walkable);
14541 }
14542
14543 18358 int32_t s=shiftdir;
14544
14545
4/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 18272 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
18358 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
14546 {
14547 shiftdir=-1;
14548 }
14549 else
14550 {
14551
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 15976 times.
18358 if(s==left)
14552 {
14553 2382 do
14554 {
14555 2805 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14556
14557 2805 execute(info);
14558
14559
2/2
✓ Branch 0 taken 809 times.
✓ Branch 1 taken 1996 times.
2805 if(info.isUnwalkable())
14560 {
14561
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 772 times.
809 if(x != x.getInt())
14562 {
14563 37 x.doRound();
14564 37 }
14565
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 386 times.
772 else if(hero_newstep_diag > 1)
14566 {
14567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 386 times.
386 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14568 386 hero_newstep_diag.doFloor();
14569 else --hero_newstep_diag;
14570 386 }
14571 else
14572 386 shiftdir = -1;
14573 809 }
14574
2/2
✓ Branch 0 taken 1763 times.
✓ Branch 1 taken 233 times.
1996 else if(walkable)
14575 {
14576 1763 do
14577 {
14578 1768 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14579 1768 execute(info);
14580
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1760 times.
1768 if(info.isUnwalkable())
14581 {
14582
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if(x != x.getInt())
14583 {
14584 2 x.doRound();
14585 2 }
14586
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14587 {
14588
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14589 3 hero_newstep_diag.doFloor();
14590 else --hero_newstep_diag;
14591 3 }
14592 else
14593 3 shiftdir = -1;
14594 8 }
14595 1760 else break;
14596
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 }
14597 8 while(shiftdir != -1);
14598 1763 break;
14599 }
14600 233 else break;
14601
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 386 times.
809 }
14602 809 while(shiftdir != -1);
14603 2382 }
14604
2/2
✓ Branch 0 taken 13842 times.
✓ Branch 1 taken 2134 times.
15976 else if(s==right)
14605 {
14606 2134 do
14607 {
14608 2458 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14609
14610 2458 execute(info);
14611
14612
2/2
✓ Branch 0 taken 611 times.
✓ Branch 1 taken 1847 times.
2458 if(info.isUnwalkable())
14613 {
14614
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 574 times.
611 if(x != x.getInt())
14615 {
14616 37 x.doRound();
14617 37 }
14618
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 287 times.
574 else if(hero_newstep_diag > 1)
14619 {
14620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287 times.
287 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14621 287 hero_newstep_diag.doFloor();
14622 else --hero_newstep_diag;
14623 287 }
14624 else
14625 287 shiftdir = -1;
14626 611 }
14627
2/2
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 227 times.
1847 else if(walkable)
14628 {
14629 1620 do
14630 {
14631 1626 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14632 1626 execute(info);
14633
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1615 times.
1626 if(info.isUnwalkable())
14634 {
14635
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14636 {
14637 1 x.doRound();
14638 1 }
14639
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14640 {
14641
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14642 5 hero_newstep_diag.doFloor();
14643 else --hero_newstep_diag;
14644 5 }
14645 else
14646 5 shiftdir = -1;
14647 11 }
14648 1615 else break;
14649
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14650 11 while(shiftdir != -1);
14651 1620 break;
14652 }
14653 227 else break;
14654
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 287 times.
611 }
14655 611 while(shiftdir != -1);
14656 2134 }
14657 }
14658
14659 18358 moveOld2(up);
14660 18358 shiftdir=s;
14661
14662
2/2
✓ Branch 0 taken 15974 times.
✓ Branch 1 taken 2384 times.
18358 if(!walkable)
14663 {
14664
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 1853 times.
2384 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14665 {
14666 1853 x = x.getInt();
14667 1853 y = y.getInt();
14668
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1853 times.
✓ Branch 4 taken 1558 times.
✓ Branch 5 taken 295 times.
✓ Branch 6 taken 127 times.
✓ Branch 7 taken 1726 times.
2148 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14669
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 295 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 161 times.
✓ Branch 5 taken 134 times.
295 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14670
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134 times.
134 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14671 {
14672
7/12
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 123 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 123 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 127 times.
127 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
14673 127 sprite::move((zfix)-1,(zfix)0);
14674 127 }
14675 else
14676 {
14677
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1726 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1726 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 1558 times.
✓ Branch 6 taken 129 times.
✓ Branch 7 taken 1597 times.
3284 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14678
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1558 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 1429 times.
✓ Branch 5 taken 129 times.
1558 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14679
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14680 {
14681
6/12
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 129 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 129 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 129 times.
129 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
14682 129 sprite::move((zfix)1,(zfix)0);
14683 129 }
14684 else
14685 {
14686 1597 pushing=push+1;
14687 }
14688 }
14689 1853 }
14690 else
14691 {
14692 531 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14693 }
14694 2384 }
14695
14696 18358 return;
14697 }
14698 }
14699
14700
6/6
✓ Branch 0 taken 23576 times.
✓ Branch 1 taken 96236 times.
✓ Branch 2 taken 22727 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 17004 times.
✓ Branch 5 taken 5723 times.
119812 if(DrunkDown()&&(holddir==-1||holddir==down))
14701 {
14702
4/8
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 17720 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17853 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
14703 {
14704 }
14705 else
14706 {
14707
4/10
✓ Branch 0 taken 17853 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17853 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17853 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17853 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
17853 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
14708 {
14709 17853 dir=down;
14710 17853 }
14711
14712 17853 holddir=down;
14713
14714
4/4
✓ Branch 0 taken 2647 times.
✓ Branch 1 taken 15206 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2645 times.
17853 if(DrunkRight()&&shiftdir!=left)
14715 {
14716 2645 shiftdir=right;
14717
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2645 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2645 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14718
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2645 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2645 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14719 2645 }
14720
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 12664 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2543 times.
15208 else if(DrunkLeft()&&shiftdir!=right)
14721 {
14722 2543 shiftdir=left;
14723
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2543 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14724
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2543 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14725 2543 }
14726 else
14727 {
14728 12665 shiftdir=-1;
14729 }
14730
14731 //bool walkable;
14732
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 17853 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
17853 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14733 {
14734 walkable=false;
14735 }
14736 else
14737 {
14738 17853 do
14739 {
14740 19772 info = walkflag(x,15+(y+hero_newstep),2,down);
14741
14742
2/2
✓ Branch 0 taken 11698 times.
✓ Branch 1 taken 8074 times.
19772 if(x.getFloor() & 7)
14743 11698 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14744 else
14745 8074 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14746
14747 19772 execute(info);
14748
14749
2/2
✓ Branch 0 taken 3606 times.
✓ Branch 1 taken 16166 times.
19772 if(info.isUnwalkable())
14750 {
14751
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 3388 times.
3606 if(y != y.getInt())
14752 {
14753 218 y.doRound();
14754 218 }
14755
2/2
✓ Branch 0 taken 1701 times.
✓ Branch 1 taken 1687 times.
3388 else if(hero_newstep > 1)
14756 {
14757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1701 times.
1701 if(hero_newstep != int32_t(hero_newstep)) //floor
14758 1701 hero_newstep = floor((double)hero_newstep);
14759 else --hero_newstep;
14760 1701 }
14761 else
14762 1687 break;
14763 1919 }
14764 16166 else walkable = true;
14765
2/2
✓ Branch 0 taken 1919 times.
✓ Branch 1 taken 16166 times.
18085 }
14766 18085 while(!walkable);
14767 }
14768
14769 17853 int32_t s=shiftdir;
14770
14771
4/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 17720 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
17853 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
14772 {
14773 shiftdir=-1;
14774 }
14775 else
14776 {
14777
2/2
✓ Branch 0 taken 2543 times.
✓ Branch 1 taken 15310 times.
17853 if(s==left)
14778 {
14779 2543 do
14780 {
14781 2932 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14782
14783 2932 execute(info);
14784
14785
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 2207 times.
2932 if(info.isUnwalkable())
14786 {
14787
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 672 times.
725 if(x != x.getInt())
14788 {
14789 53 x.doRound();
14790 53 }
14791
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 336 times.
672 else if(hero_newstep_diag > 1)
14792 {
14793
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14794 336 hero_newstep_diag.doFloor();
14795 else --hero_newstep_diag;
14796 336 }
14797 else
14798 336 shiftdir = -1;
14799 725 }
14800
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 242 times.
2207 else if(walkable)
14801 {
14802 1965 do
14803 {
14804 1972 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14805 1972 execute(info);
14806
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1962 times.
1972 if(info.isUnwalkable())
14807 {
14808
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14809 {
14810 4 x.doRound();
14811 4 }
14812
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14813 {
14814
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14815 3 hero_newstep_diag.doFloor();
14816 else --hero_newstep_diag;
14817 3 }
14818 else
14819 3 shiftdir = -1;
14820 10 }
14821 1962 else break;
14822
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14823 10 while(shiftdir != -1);
14824 1965 break;
14825 }
14826 242 else break;
14827
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 336 times.
725 }
14828 725 while(shiftdir != -1);
14829 2543 }
14830
2/2
✓ Branch 0 taken 12665 times.
✓ Branch 1 taken 2645 times.
15310 else if(s==right)
14831 {
14832 2645 do
14833 {
14834 2987 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14835
14836 2987 execute(info);
14837
14838
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 2327 times.
2987 if(info.isUnwalkable())
14839 {
14840
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 636 times.
660 if(x != x.getInt())
14841 {
14842 24 x.doRound();
14843 24 }
14844
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 318 times.
636 else if(hero_newstep_diag > 1)
14845 {
14846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14847 318 hero_newstep_diag.doFloor();
14848 else --hero_newstep_diag;
14849 318 }
14850 else
14851 318 shiftdir = -1;
14852 660 }
14853
2/2
✓ Branch 0 taken 2076 times.
✓ Branch 1 taken 251 times.
2327 else if(walkable)
14854 {
14855 2076 do
14856 {
14857 2082 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14858 2082 execute(info);
14859
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2071 times.
2082 if(info.isUnwalkable())
14860 {
14861
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14862 {
14863 1 x.doRound();
14864 1 }
14865
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14866 {
14867
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14868 5 hero_newstep_diag.doFloor();
14869 else --hero_newstep_diag;
14870 5 }
14871 else
14872 5 shiftdir = -1;
14873 11 }
14874 2071 else break;
14875
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14876 11 while(shiftdir != -1);
14877 2076 break;
14878 }
14879 251 else break;
14880
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 318 times.
660 }
14881 660 while(shiftdir != -1);
14882 2645 }
14883 }
14884
14885 17853 moveOld2(down);
14886 17853 shiftdir=s;
14887
14888
2/2
✓ Branch 0 taken 16166 times.
✓ Branch 1 taken 1687 times.
17853 if(!walkable)
14889 {
14890
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 1164 times.
1687 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14891 {
14892 1164 x = x.getInt();
14893 1164 y = y.getInt();
14894
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1164 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1164 times.
✓ Branch 4 taken 928 times.
✓ Branch 5 taken 236 times.
✓ Branch 6 taken 134 times.
✓ Branch 7 taken 1030 times.
1400 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14895
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 236 times.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 134 times.
236 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14896
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134 times.
134 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14897 {
14898
6/12
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 134 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 134 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 134 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 134 times.
134 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
14899 134 sprite::move((zfix)-1,(zfix)0);
14900 134 }
14901
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1030 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1030 times.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 928 times.
✓ Branch 6 taken 153 times.
✓ Branch 7 taken 877 times.
1958 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14902
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 928 times.
✓ Branch 4 taken 775 times.
✓ Branch 5 taken 153 times.
928 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14903
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153 times.
153 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14904 {
14905
6/12
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 153 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 153 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 153 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 153 times.
153 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
14906 153 sprite::move((zfix)1,(zfix)0);
14907 153 }
14908 else
14909 {
14910 877 pushing=push+1;
14911 }
14912 1164 }
14913 else
14914 {
14915 523 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14916 }
14917 1687 }
14918
14919 17853 return;
14920 }
14921 }
14922
14923
6/6
✓ Branch 0 taken 25086 times.
✓ Branch 1 taken 76873 times.
✓ Branch 2 taken 24179 times.
✓ Branch 3 taken 907 times.
✓ Branch 4 taken 24171 times.
✓ Branch 5 taken 8 times.
101959 if(DrunkLeft()&&(holddir==-1||holddir==left))
14924 {
14925
4/8
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 25021 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25078 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
14926 {
14927 }
14928 else
14929 {
14930
3/6
✓ Branch 0 taken 25078 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25078 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25078 times.
25078 if(charging==0 && spins==0 && action != sideswimattacking)
14931 {
14932 25078 dir=left;
14933 25078 }
14934 25078 sideswimdir = left;
14935
14936 25078 holddir=left;
14937
14938
3/4
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 21800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278 times.
25078 if(DrunkUp()&&shiftdir!=down)
14939 {
14940 3278 shiftdir=up;
14941 3278 }
14942
4/4
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 19013 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2786 times.
21800 else if(DrunkDown()&&shiftdir!=up)
14943 {
14944 2786 shiftdir=down;
14945 2786 }
14946 else
14947 {
14948 19014 shiftdir=-1;
14949 }
14950
14951 25078 do
14952 {
14953 27757 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14954
14955 27757 info = info || walkflag(x-hero_newstep,y+15,1,left);
14956
14957 27757 execute(info);
14958
14959
2/2
✓ Branch 0 taken 5137 times.
✓ Branch 1 taken 22620 times.
27757 if(info.isUnwalkable())
14960 {
14961
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4916 times.
5137 if(x != x.getInt())
14962 {
14963 221 x.doRound();
14964 221 }
14965
2/2
✓ Branch 0 taken 2458 times.
✓ Branch 1 taken 2458 times.
4916 else if(hero_newstep > 1)
14966 {
14967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2458 times.
2458 if(hero_newstep != int32_t(hero_newstep)) //floor
14968 2458 hero_newstep = floor((double)hero_newstep);
14969 else --hero_newstep;
14970 2458 }
14971 else
14972 2458 break;
14973 2679 }
14974 22620 else walkable = true;
14975
2/2
✓ Branch 0 taken 2679 times.
✓ Branch 1 taken 22620 times.
25299 }
14976 25299 while(!walkable);
14977
14978 25078 int32_t s=shiftdir;
14979
14980
5/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 25021 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 25078 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
25078 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14981 {
14982 shiftdir=-1;
14983 }
14984 else
14985 {
14986
2/2
✓ Branch 0 taken 21800 times.
✓ Branch 1 taken 3278 times.
25078 if(s==up)
14987 {
14988 3278 do
14989 {
14990 3755 zfix ty = y - hero_newstep_diag;
14991 7510 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14992 3755 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14993
14994
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3754 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3755 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14995 {
14996 1 info = info || walkflag(x, zfix(0), 2, up);
14997 1 info = info || walkflag(x+15, zfix(0), 1, up);
14998 1 }
14999 3755 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15000
15001 3755 execute(info);
15002
15003
2/2
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 2849 times.
3755 if(info.isUnwalkable())
15004 {
15005
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 858 times.
906 if(y != y.getInt())
15006 {
15007 48 y.doRound();
15008 48 }
15009
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 429 times.
858 else if(hero_newstep_diag > 1)
15010 {
15011
1/2
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
429 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15012 429 hero_newstep_diag.doFloor();
15013 else --hero_newstep_diag;
15014 429 }
15015 else
15016 429 shiftdir = -1;
15017 906 }
15018
2/2
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 517 times.
2849 else if(walkable)
15019 {
15020 2332 do
15021 {
15022 2354 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
15023 2354 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
15024
15025
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2354 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15026 {
15027 1 info = info || walkflag(tx, zfix(0), 1, up);
15028 1 info = info || walkflag(tx+15, zfix(0), 1, up);
15029 1 }
15030 2354 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15031
15032 2354 execute(info);
15033
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2319 times.
2354 if(info.isUnwalkable())
15034 {
15035
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
15036 {
15037 9 y.doRound();
15038 9 }
15039
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
15040 {
15041
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15042 13 hero_newstep_diag.doFloor();
15043 else --hero_newstep_diag;
15044 13 }
15045 else
15046 13 shiftdir = -1;
15047 35 }
15048 2319 else break;
15049
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
15050 35 while(shiftdir != -1);
15051 2332 break;
15052 }
15053 517 else break;
15054
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 429 times.
906 }
15055 906 while(shiftdir != -1);
15056 3278 }
15057
2/2
✓ Branch 0 taken 19014 times.
✓ Branch 1 taken 2786 times.
21800 else if(s==down)
15058 {
15059 2786 do
15060 {
15061 3234 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15062
15063 3234 execute(info);
15064
15065
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 2386 times.
3234 if(info.isUnwalkable())
15066 {
15067
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 800 times.
848 if(y != y.getInt())
15068 {
15069 48 y.doRound();
15070 48 }
15071
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 400 times.
800 else if(hero_newstep_diag > 1)
15072 {
15073
1/2
✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
400 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15074 400 hero_newstep_diag.doFloor();
15075 else --hero_newstep_diag;
15076 400 }
15077 else
15078 400 shiftdir = -1;
15079 848 }
15080
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 384 times.
2386 else if(walkable)
15081 {
15082 2002 do
15083 {
15084 2005 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
15085 2005 execute(info);
15086
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2000 times.
2005 if(info.isUnwalkable())
15087 {
15088
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
15089 {
15090 1 y.doRound();
15091 1 }
15092
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
15093 {
15094
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15095 2 hero_newstep_diag.doFloor();
15096 else --hero_newstep_diag;
15097 2 }
15098 else
15099 2 shiftdir = -1;
15100 5 }
15101 2000 else break;
15102
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
15103 5 while(shiftdir != -1);
15104 2002 break;
15105 }
15106 384 else break;
15107
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 400 times.
848 }
15108 848 while(shiftdir != -1);
15109 2786 }
15110 }
15111
15112 25078 moveOld2(left);
15113 25078 shiftdir=s;
15114
15115
2/2
✓ Branch 0 taken 22620 times.
✓ Branch 1 taken 2458 times.
25078 if(!walkable)
15116 {
15117
2/2
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 1485 times.
2458 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15118 {
15119 1485 x = x.getInt();
15120 1485 y = y.getInt();
15121 1485 int32_t v1=bigHitbox?0:8;
15122 1485 int32_t v2=bigHitbox?8:12;
15123
15124
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1485 times.
✓ Branch 2 taken 1485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1297 times.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 1454 times.
1673 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15125
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 31 times.
188 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15126
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15127 {
15128
6/12
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 31 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 31 times.
31 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15129 31 sprite::move((zfix)0,(zfix)-1);
15130 31 }
15131
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1454 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 1297 times.
✓ Branch 6 taken 37 times.
✓ Branch 7 taken 1417 times.
2751 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15132
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1297 times.
✓ Branch 4 taken 1260 times.
✓ Branch 5 taken 37 times.
1297 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15133
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37 times.
37 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15134 {
15135
6/12
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 37 times.
37 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15136 37 sprite::move((zfix)0,(zfix)1);
15137 37 }
15138 else
15139 {
15140 1417 pushing=push+1;
15141 }
15142 1485 }
15143 else
15144 {
15145 973 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15146
15147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 973 times.
973 if(action!=swimming)
15148 {
15149 973 }
15150 }
15151 2458 }
15152
15153 25078 return;
15154 }
15155 }
15156
15157
5/6
✓ Branch 0 taken 27412 times.
✓ Branch 1 taken 49469 times.
✓ Branch 2 taken 26471 times.
✓ Branch 3 taken 941 times.
✓ Branch 4 taken 26471 times.
✗ Branch 5 not taken.
76881 if(DrunkRight()&&(holddir==-1||holddir==right))
15158 {
15159
4/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 27254 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
27412 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15160 {
15161 }
15162 else
15163 {
15164
3/6
✓ Branch 0 taken 27412 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27412 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 27412 times.
27412 if(charging==0 && spins==0 && action != sideswimattacking)
15165 {
15166 27412 dir=right;
15167 27412 }
15168 27412 sideswimdir = right;
15169
15170 27412 holddir=right;
15171
15172
3/4
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 24349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3063 times.
27412 if(DrunkUp()&&shiftdir!=down)
15173 {
15174 3063 shiftdir=up;
15175 3063 }
15176
4/4
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 21415 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2932 times.
24349 else if(DrunkDown()&&shiftdir!=up)
15177 {
15178 2932 shiftdir=down;
15179 2932 }
15180 else
15181 {
15182 21417 shiftdir=-1;
15183 }
15184
15185 27412 do
15186 {
15187 30107 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
15188
15189 30107 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
15190
15191 30107 execute(info);
15192
15193
2/2
✓ Branch 0 taken 5147 times.
✓ Branch 1 taken 24960 times.
30107 if(info.isUnwalkable())
15194 {
15195
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 4926 times.
5147 if(x != x.getInt())
15196 {
15197 221 x.doRound();
15198 221 }
15199
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 2452 times.
4926 else if(hero_newstep > 1)
15200 {
15201
1/2
✓ Branch 0 taken 2474 times.
✗ Branch 1 not taken.
2474 if(hero_newstep != int32_t(hero_newstep)) //floor
15202 2474 hero_newstep = floor((double)hero_newstep);
15203 else --hero_newstep;
15204 2474 }
15205 else
15206 2452 break;
15207 2695 }
15208 24960 else walkable = true;
15209
2/2
✓ Branch 0 taken 2695 times.
✓ Branch 1 taken 24960 times.
27655 }
15210 27655 while(!walkable);
15211
15212 27412 int32_t s=shiftdir;
15213
15214
10/14
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 27254 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 563 times.
✓ Branch 7 taken 26849 times.
✓ Branch 8 taken 563 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 563 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 563 times.
✗ Branch 13 not taken.
27412 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15215 {
15216 563 shiftdir=-1;
15217 563 }
15218 else
15219 {
15220
2/2
✓ Branch 0 taken 23786 times.
✓ Branch 1 taken 3063 times.
26849 if(s==up)
15221 {
15222 3063 do
15223 {
15224 3364 zfix ty = y - hero_newstep_diag;
15225 6728 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15226 3364 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15227
15228
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3364 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15229 {
15230 1 info = info || walkflag(x, zfix(0), 2, up);
15231 1 info = info || walkflag(x+15, zfix(0), 1, up);
15232 1 }
15233 3364 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15234
15235 3364 execute(info);
15236
15237
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 2805 times.
3364 if(info.isUnwalkable())
15238 {
15239
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 516 times.
559 if(y != y.getInt())
15240 {
15241 43 y.doRound();
15242 43 }
15243
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 258 times.
516 else if(hero_newstep_diag > 1)
15244 {
15245
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
258 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15246 258 hero_newstep_diag.doFloor();
15247 else --hero_newstep_diag;
15248 258 }
15249 else
15250 258 shiftdir = -1;
15251 559 }
15252
2/2
✓ Branch 0 taken 2468 times.
✓ Branch 1 taken 337 times.
2805 else if(walkable)
15253 {
15254 2468 do
15255 {
15256 2487 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
15257 2487 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
15258
15259
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2486 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
2487 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15260 {
15261 1 info = info || walkflag(tx, zfix(0), 1, up);
15262 1 info = info || walkflag(tx+15, zfix(0), 1, up);
15263 1 }
15264 2487 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15265 2487 execute(info);
15266
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2457 times.
2487 if(info.isUnwalkable())
15267 {
15268
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 22 times.
30 if(y != y.getInt())
15269 {
15270 8 y.doRound();
15271 8 }
15272
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
15273 {
15274
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15275 11 hero_newstep_diag.doFloor();
15276 else --hero_newstep_diag;
15277 11 }
15278 else
15279 11 shiftdir = -1;
15280 30 }
15281 2457 else break;
15282
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 11 times.
30 }
15283 30 while(shiftdir != -1);
15284 2468 break;
15285 }
15286 337 else break;
15287
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 258 times.
559 }
15288 559 while(shiftdir != -1);
15289 3063 }
15290
2/2
✓ Branch 0 taken 20854 times.
✓ Branch 1 taken 2932 times.
23786 else if(s==down)
15291 {
15292 2932 do
15293 {
15294 3432 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15295
15296 3432 execute(info);
15297
15298
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 2494 times.
3432 if(info.isUnwalkable())
15299 {
15300
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 876 times.
938 if(y != y.getInt())
15301 {
15302 62 y.doRound();
15303 62 }
15304
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 438 times.
876 else if(hero_newstep_diag > 1)
15305 {
15306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 438 times.
438 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15307 438 hero_newstep_diag.doFloor();
15308 else --hero_newstep_diag;
15309 438 }
15310 else
15311 438 shiftdir = -1;
15312 938 }
15313
2/2
✓ Branch 0 taken 2134 times.
✓ Branch 1 taken 360 times.
2494 else if(walkable)
15314 {
15315 2134 do
15316 {
15317 2146 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15318 2146 execute(info);
15319
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2127 times.
2146 if(info.isUnwalkable())
15320 {
15321
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(y != y.getInt())
15322 {
15323 4 y.doRound();
15324 4 }
15325
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 else if(hero_newstep_diag > 1)
15326 {
15327
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15328 8 hero_newstep_diag.doFloor();
15329 else --hero_newstep_diag;
15330 8 }
15331 else
15332 7 shiftdir = -1;
15333 19 }
15334 2127 else break;
15335
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 }
15336 19 while(shiftdir != -1);
15337 2134 break;
15338 }
15339 360 else break;
15340
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 438 times.
938 }
15341 938 while(shiftdir != -1);
15342 2932 }
15343 }
15344
15345 27412 moveOld2(right);
15346 27412 shiftdir=s;
15347
15348
2/2
✓ Branch 0 taken 24960 times.
✓ Branch 1 taken 2452 times.
27412 if(!walkable)
15349 {
15350
2/2
✓ Branch 0 taken 752 times.
✓ Branch 1 taken 1700 times.
2452 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15351 {
15352 1700 x = x.getInt();
15353 1700 y = y.getInt();
15354 1700 int32_t v1=bigHitbox?0:8;
15355 1700 int32_t v2=bigHitbox?8:12;
15356
15357
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1700 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1700 times.
✓ Branch 4 taken 1564 times.
✓ Branch 5 taken 136 times.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1653 times.
1836 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15358
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 47 times.
136 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
15359
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15360 {
15361
6/12
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 47 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 47 times.
47 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15362 47 sprite::move((zfix)0,(zfix)-1);
15363 47 }
15364
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1653 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1653 times.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 1564 times.
✓ Branch 6 taken 58 times.
✓ Branch 7 taken 1595 times.
3217 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15365
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1564 times.
✓ Branch 4 taken 1506 times.
✓ Branch 5 taken 58 times.
1564 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
15366
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
58 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15367 {
15368
6/12
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 58 times.
58 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15369 58 sprite::move((zfix)0,(zfix)1);
15370 58 }
15371 else
15372 {
15373 1595 pushing=push+1;
15374 1595 z3step=2;
15375 }
15376 1700 }
15377 else
15378 {
15379 752 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15380
15381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 752 times.
752 if(action!=swimming)
15382 {
15383 752 }
15384 }
15385 2452 }
15386
15387 27412 return;
15388 }
15389 }
15390 49469 }
15391 else
15392 {
15393
6/6
✓ Branch 0 taken 98623 times.
✓ Branch 1 taken 615816 times.
✓ Branch 2 taken 96183 times.
✓ Branch 3 taken 2440 times.
✓ Branch 4 taken 25359 times.
✓ Branch 5 taken 70824 times.
714439 if(DrunkUp()&&(holddir==-1||holddir==up))
15394 {
15395
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73264 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15396 {
15397 }
15398 else
15399 {
15400
2/4
✓ Branch 0 taken 73264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73264 times.
73264 if(charging==0 && spins==0)
15401 {
15402 73264 dir=up;
15403 73264 }
15404
15405 73264 holddir=up;
15406
15407
4/4
✓ Branch 0 taken 10460 times.
✓ Branch 1 taken 62804 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 10441 times.
73264 if(DrunkRight()&&shiftdir!=left)
15408 {
15409 10441 shiftdir=right;
15410 10441 }
15411
4/4
✓ Branch 0 taken 7700 times.
✓ Branch 1 taken 55123 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 7688 times.
62823 else if(DrunkLeft()&&shiftdir!=right)
15412 {
15413 7688 shiftdir=left;
15414 7688 }
15415 else
15416 {
15417 55135 shiftdir=-1;
15418 }
15419
15420 //walkable if Ladder can be placed or is already placed vertically
15421
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 56779 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
73264 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15422 {
15423 16354 walkable=false;
15424 16354 }
15425 else
15426 {
15427 56910 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15428
15429
2/2
✓ Branch 0 taken 28808 times.
✓ Branch 1 taken 28102 times.
56910 if(x.getInt() & 7)
15430 28808 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15431 else
15432 28102 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15433
15434 56910 execute(info);
15435
15436
2/2
✓ Branch 0 taken 7074 times.
✓ Branch 1 taken 49836 times.
56910 if(info.isUnwalkable())
15437 {
15438
2/2
✓ Branch 0 taken 6878 times.
✓ Branch 1 taken 196 times.
7074 if(z3step==2)
15439 {
15440 6878 z3step=1;
15441 6878 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15442
15443
2/2
✓ Branch 0 taken 3684 times.
✓ Branch 1 taken 3194 times.
6878 if(x.getInt()&7)
15444 3684 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15445 else
15446 3194 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15447
15448 6878 execute(info);
15449
15450
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 309 times.
6878 if(info.isUnwalkable())
15451 {
15452 6569 walkable = false;
15453 6569 }
15454 else
15455 {
15456 309 walkable=true;
15457 }
15458 6878 }
15459 else
15460 {
15461 196 walkable=false;
15462 }
15463 7074 }
15464 else
15465 {
15466 49836 walkable = true;
15467 }
15468 }
15469
15470 73264 int32_t s=shiftdir;
15471
15472
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 73264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
73264 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15473 {
15474 shiftdir=-1;
15475 }
15476 else
15477 {
15478
2/2
✓ Branch 0 taken 7688 times.
✓ Branch 1 taken 65576 times.
73264 if(s==left)
15479 {
15480 7688 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15481 7688 execute(info);
15482
15483
2/2
✓ Branch 0 taken 835 times.
✓ Branch 1 taken 6853 times.
7688 if(info.isUnwalkable())
15484 {
15485 835 shiftdir=-1;
15486 835 }
15487
2/2
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 4952 times.
6853 else if(walkable)
15488 {
15489 4952 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15490 4952 execute(info);
15491
2/2
✓ Branch 0 taken 4943 times.
✓ Branch 1 taken 9 times.
4952 if(info.isUnwalkable())
15492 {
15493 9 shiftdir=-1;
15494 9 }
15495 4952 }
15496 7688 }
15497
2/2
✓ Branch 0 taken 55135 times.
✓ Branch 1 taken 10441 times.
65576 else if(s==right)
15498 {
15499 10441 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15500 10441 execute(info);
15501
15502
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 9170 times.
10441 if(info.isUnwalkable())
15503 {
15504 1271 shiftdir=-1;
15505 1271 }
15506
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 6724 times.
9170 else if(walkable)
15507 {
15508 6724 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15509 6724 execute(info);
15510
15511
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 9 times.
6724 if(info.isUnwalkable())
15512 {
15513 9 shiftdir=-1;
15514 9 }
15515 6724 }
15516 10441 }
15517 }
15518
15519 73264 moveOld2(up);
15520 73264 shiftdir=s;
15521
15522
2/2
✓ Branch 0 taken 50145 times.
✓ Branch 1 taken 23119 times.
73264 if(!walkable)
15523 {
15524
2/2
✓ Branch 0 taken 5029 times.
✓ Branch 1 taken 18090 times.
23119 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15525 {
15526
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 18090 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18090 times.
✓ Branch 4 taken 3983 times.
✓ Branch 5 taken 14107 times.
✓ Branch 6 taken 274 times.
✓ Branch 7 taken 17816 times.
32197 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15527
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14107 times.
✓ Branch 4 taken 324 times.
✓ Branch 5 taken 13783 times.
14107 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15528
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13783 times.
13783 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15529 {
15530
7/12
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 259 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 259 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 274 times.
274 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
15531 274 sprite::move((zfix)-1,(zfix)0);
15532 274 }
15533 else
15534 {
15535
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 17816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17816 times.
✓ Branch 4 taken 13833 times.
✓ Branch 5 taken 3983 times.
✓ Branch 6 taken 239 times.
✓ Branch 7 taken 17577 times.
21799 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15536
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3983 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3983 times.
✓ Branch 4 taken 3744 times.
✓ Branch 5 taken 239 times.
3983 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15537
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 239 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 239 times.
239 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15538 {
15539
7/12
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 233 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 233 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 233 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 233 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 239 times.
239 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
15540 239 sprite::move((zfix)1,(zfix)0);
15541 239 }
15542 else
15543 {
15544 17577 pushing=push+1;
15545 }
15546 }
15547
15548 18090 z3step=2;
15549 18090 }
15550 else
15551 {
15552 5029 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15553 5029 z3step=2;
15554 }
15555 23119 }
15556
15557 73264 return;
15558 }
15559 }
15560
15561
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 569262 times.
✓ Branch 2 taken 69941 times.
✓ Branch 3 taken 1972 times.
✓ Branch 4 taken 50444 times.
✓ Branch 5 taken 19497 times.
641175 if(DrunkDown()&&(holddir==-1||holddir==down))
15562 {
15563
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 52416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52416 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
15564 {
15565 }
15566 else
15567 {
15568
2/4
✓ Branch 0 taken 52416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 52416 times.
52416 if(charging==0 && spins==0)
15569 {
15570 52416 dir=down;
15571 52416 }
15572
15573 52416 holddir=down;
15574
15575
4/4
✓ Branch 0 taken 8539 times.
✓ Branch 1 taken 43877 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 8520 times.
52416 if(DrunkRight()&&shiftdir!=left)
15576 {
15577 8520 shiftdir=right;
15578 8520 }
15579
4/4
✓ Branch 0 taken 7486 times.
✓ Branch 1 taken 36410 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7480 times.
43896 else if(DrunkLeft()&&shiftdir!=right)
15580 {
15581 7480 shiftdir=left;
15582 7480 }
15583 else
15584 {
15585 36416 shiftdir=-1;
15586 }
15587
15588 //bool walkable;
15589
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 43271 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
52416 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15590 {
15591 9145 walkable=false;
15592 9145 }
15593 else
15594 {
15595 43271 info = walkflag(x,y+15+z3step,2,down);
15596
15597
2/2
✓ Branch 0 taken 22930 times.
✓ Branch 1 taken 20341 times.
43271 if(x.getInt()&7)
15598 22930 info = info || walkflag(x+16,y+15+z3step,1,down);
15599 else
15600 20341 info = info || walkflagMBlock(x+16, y+15+z3step);
15601
15602 43271 execute(info);
15603
15604
2/2
✓ Branch 0 taken 5447 times.
✓ Branch 1 taken 37824 times.
43271 if(info.isUnwalkable())
15605 {
15606
2/2
✓ Branch 0 taken 5309 times.
✓ Branch 1 taken 138 times.
5447 if(z3step==2)
15607 {
15608 5309 z3step=1;
15609 5309 info = walkflag(x,y+15+z3step,2,down);
15610
15611
2/2
✓ Branch 0 taken 3020 times.
✓ Branch 1 taken 2289 times.
5309 if(x.getInt()&7)
15612 3020 info = info || walkflag(x+16,y+15+z3step,1,down);
15613 else
15614 2289 info = info || walkflagMBlock(x+16, y+15+z3step);
15615
15616 5309 execute(info);
15617
15618
2/2
✓ Branch 0 taken 5054 times.
✓ Branch 1 taken 255 times.
5309 if(info.isUnwalkable())
15619 {
15620 5054 walkable = false;
15621 5054 }
15622 else
15623 {
15624 255 walkable=true;
15625 }
15626 5309 }
15627 else
15628 {
15629 138 walkable=false;
15630 }
15631 5447 }
15632 else
15633 {
15634 37824 walkable = true;
15635 }
15636 }
15637
15638 52416 int32_t s=shiftdir;
15639
15640
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52416 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52416 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM))
15641 {
15642 shiftdir=-1;
15643 }
15644 else
15645 {
15646
2/2
✓ Branch 0 taken 7480 times.
✓ Branch 1 taken 44936 times.
52416 if(s==left)
15647 {
15648 7480 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15649 7480 execute(info);
15650
15651
2/2
✓ Branch 0 taken 870 times.
✓ Branch 1 taken 6610 times.
7480 if(info.isUnwalkable())
15652 {
15653 870 shiftdir=-1;
15654 870 }
15655
2/2
✓ Branch 0 taken 1911 times.
✓ Branch 1 taken 4699 times.
6610 else if(walkable)
15656 {
15657 4699 info = walkflag(x-1,y+16,1,left);
15658 4699 execute(info);
15659
15660
2/2
✓ Branch 0 taken 4688 times.
✓ Branch 1 taken 11 times.
4699 if(info.isUnwalkable())
15661 {
15662 11 shiftdir=-1;
15663 11 }
15664 4699 }
15665 7480 }
15666
2/2
✓ Branch 0 taken 36416 times.
✓ Branch 1 taken 8520 times.
44936 else if(s==right)
15667 {
15668 8520 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15669 8520 execute(info);
15670
15671
2/2
✓ Branch 0 taken 1061 times.
✓ Branch 1 taken 7459 times.
8520 if(info.isUnwalkable())
15672 {
15673 1061 shiftdir=-1;
15674 1061 }
15675
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 5494 times.
7459 else if(walkable)
15676 {
15677 5494 info = walkflag(x+16,y+16,1,right);
15678 5494 execute(info);
15679
15680
2/2
✓ Branch 0 taken 5479 times.
✓ Branch 1 taken 15 times.
5494 if(info.isUnwalkable())
15681 {
15682 15 shiftdir=-1;
15683 15 }
15684 5494 }
15685 8520 }
15686 }
15687
15688 52416 moveOld2(down);
15689 52416 shiftdir=s;
15690
15691
2/2
✓ Branch 0 taken 38079 times.
✓ Branch 1 taken 14337 times.
52416 if(!walkable)
15692 {
15693
2/2
✓ Branch 0 taken 4314 times.
✓ Branch 1 taken 10023 times.
14337 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15694 {
15695
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10023 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10023 times.
✓ Branch 4 taken 4071 times.
✓ Branch 5 taken 5952 times.
✓ Branch 6 taken 182 times.
✓ Branch 7 taken 9841 times.
15975 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15696
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5952 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5952 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 5658 times.
5952 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15697
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5658 times.
5658 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15698 {
15699
6/12
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 182 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 182 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 182 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 182 times.
182 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
15700 182 sprite::move((zfix)-1,(zfix)0);
15701 182 }
15702
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9841 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9841 times.
✓ Branch 4 taken 5770 times.
✓ Branch 5 taken 4071 times.
✓ Branch 6 taken 202 times.
✓ Branch 7 taken 9639 times.
13912 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15703
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4071 times.
✓ Branch 4 taken 3869 times.
✓ Branch 5 taken 202 times.
4071 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15704
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 202 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202 times.
202 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15705 {
15706
7/12
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 180 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 180 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 202 times.
202 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
15707 202 sprite::move((zfix)1,(zfix)0);
15708 202 }
15709 else //if(shiftdir==-1)
15710 {
15711 9639 pushing=push+1;
15712
15713
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 9554 times.
9639 if(action!=swimming)
15714 {
15715 9554 }
15716 }
15717
15718 10023 z3step=2;
15719 10023 }
15720 else
15721 {
15722 4314 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15723
15724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4314 times.
4314 if(action!=swimming)
15725 {
15726 4314 }
15727
15728 4314 z3step=2;
15729 }
15730 14337 }
15731
15732 52416 return;
15733 }
15734 }
15735
15736
6/6
✓ Branch 0 taken 154026 times.
✓ Branch 1 taken 434733 times.
✓ Branch 2 taken 149367 times.
✓ Branch 3 taken 4659 times.
✓ Branch 4 taken 149045 times.
✓ Branch 5 taken 322 times.
588759 if(DrunkLeft()&&(holddir==-1||holddir==left))
15737 {
15738
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 153704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
153704 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15739 {
15740 }
15741 else
15742 {
15743
2/4
✓ Branch 0 taken 153704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 153704 times.
153704 if(charging==0 && spins==0)
15744 {
15745 153704 dir=left;
15746 153704 }
15747
15748 153704 holddir=left;
15749
15750
4/4
✓ Branch 0 taken 11561 times.
✓ Branch 1 taken 142143 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11560 times.
153704 if(DrunkUp()&&shiftdir!=down)
15751 {
15752 11560 shiftdir=up;
15753 11560 }
15754
3/4
✓ Branch 0 taken 8638 times.
✓ Branch 1 taken 133506 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8638 times.
142144 else if(DrunkDown()&&shiftdir!=up)
15755 {
15756 8638 shiftdir=down;
15757 8638 }
15758 else
15759 {
15760 133506 shiftdir=-1;
15761 }
15762
15763 //bool walkable;
15764 153704 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15765
15766
2/2
✓ Branch 0 taken 64257 times.
✓ Branch 1 taken 89447 times.
153704 if(y.getInt()&7)
15767 64257 info = info || walkflag(x-z3step,y+16,1,left);
15768
15769 153704 execute(info);
15770
15771
2/2
✓ Branch 0 taken 17431 times.
✓ Branch 1 taken 136273 times.
153704 if(info.isUnwalkable())
15772 {
15773
2/2
✓ Branch 0 taken 17044 times.
✓ Branch 1 taken 387 times.
17431 if(z3step==2)
15774 {
15775 17044 z3step=1;
15776 17044 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15777
15778
2/2
✓ Branch 0 taken 9576 times.
✓ Branch 1 taken 7468 times.
17044 if(y.getInt()&7)
15779 7468 info = info || walkflag(x-z3step,y+16,1,left);
15780
15781 17044 execute(info);
15782
15783
2/2
✓ Branch 0 taken 16555 times.
✓ Branch 1 taken 489 times.
17044 if(info.isUnwalkable())
15784 {
15785 16555 walkable = false;
15786 16555 }
15787 else
15788 {
15789 489 walkable=true;
15790 }
15791 17044 }
15792 else
15793 {
15794 387 walkable=false;
15795 }
15796 17431 }
15797 else
15798 {
15799 136273 walkable = true;
15800 }
15801
15802 153704 int32_t s=shiftdir;
15803
15804
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 153704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 97370 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
153704 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15805 {
15806 56334 shiftdir=-1;
15807 56334 }
15808 else
15809 {
15810
2/2
✓ Branch 0 taken 87101 times.
✓ Branch 1 taken 10269 times.
97370 if(s==up)
15811 {
15812 10269 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15813 10269 execute(info);
15814
15815
2/2
✓ Branch 0 taken 1058 times.
✓ Branch 1 taken 9211 times.
10269 if(info.isUnwalkable())
15816 {
15817 1058 shiftdir=-1;
15818 1058 }
15819
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 8063 times.
9211 else if(walkable)
15820 {
15821 8063 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15822 8063 execute(info);
15823
15824
2/2
✓ Branch 0 taken 8049 times.
✓ Branch 1 taken 14 times.
8063 if(info.isUnwalkable())
15825 {
15826 14 shiftdir=-1;
15827 14 }
15828 8063 }
15829 10269 }
15830
2/2
✓ Branch 0 taken 79024 times.
✓ Branch 1 taken 8077 times.
87101 else if(s==down)
15831 {
15832 8077 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15833 8077 execute(info);
15834
15835
2/2
✓ Branch 0 taken 843 times.
✓ Branch 1 taken 7234 times.
8077 if(info.isUnwalkable())
15836 {
15837 843 shiftdir=-1;
15838 843 }
15839
2/2
✓ Branch 0 taken 818 times.
✓ Branch 1 taken 6416 times.
7234 else if(walkable)
15840 {
15841 6416 info = walkflag(x-1,y+16,1,down);
15842 6416 execute(info);
15843
15844
2/2
✓ Branch 0 taken 6410 times.
✓ Branch 1 taken 6 times.
6416 if(info.isUnwalkable())
15845 {
15846 6 shiftdir=-1;
15847 6 }
15848 6416 }
15849 8077 }
15850 }
15851
15852 153704 moveOld2(left);
15853 153704 shiftdir=s;
15854
15855
2/2
✓ Branch 0 taken 136762 times.
✓ Branch 1 taken 16942 times.
153704 if(!walkable)
15856 {
15857
2/2
✓ Branch 0 taken 2426 times.
✓ Branch 1 taken 14516 times.
16942 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15858 {
15859 14516 int32_t v1=bigHitbox?0:8;
15860 14516 int32_t v2=bigHitbox?8:12;
15861
15862
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 14516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14516 times.
✓ Branch 4 taken 12786 times.
✓ Branch 5 taken 1730 times.
✓ Branch 6 taken 752 times.
✓ Branch 7 taken 13764 times.
16246 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15863
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1730 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1730 times.
✓ Branch 4 taken 891 times.
✓ Branch 5 taken 839 times.
1730 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15864
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 839 times.
839 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15865 {
15866
7/12
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 671 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 671 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 671 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 752 times.
752 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15867 752 sprite::move((zfix)0,(zfix)-1);
15868 752 }
15869
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 13764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13764 times.
✓ Branch 4 taken 978 times.
✓ Branch 5 taken 12786 times.
✓ Branch 6 taken 389 times.
✓ Branch 7 taken 13375 times.
26550 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15870
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12786 times.
✓ Branch 4 taken 12397 times.
✓ Branch 5 taken 389 times.
12786 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15871
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
389 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15872 {
15873
8/12
✓ Branch 0 taken 345 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 345 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 345 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 345 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 345 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 388 times.
389 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15874 388 sprite::move((zfix)0,(zfix)1);
15875 389 }
15876 else //if(shiftdir==-1)
15877 {
15878 13375 pushing=push+1;
15879
15880
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 13195 times.
13375 if(action!=swimming)
15881 {
15882 13195 }
15883 }
15884
15885 14516 z3step=2;
15886 14516 }
15887 else
15888 {
15889 2426 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15890
15891
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2387 times.
2426 if(action!=swimming)
15892 {
15893 2387 }
15894
15895 2426 z3step=2;
15896 }
15897 16942 }
15898
15899 153704 return;
15900 }
15901 }
15902
15903
5/6
✓ Branch 0 taken 182278 times.
✓ Branch 1 taken 252777 times.
✓ Branch 2 taken 177145 times.
✓ Branch 3 taken 5133 times.
✓ Branch 4 taken 177145 times.
✗ Branch 5 not taken.
435055 if(DrunkRight()&&(holddir==-1||holddir==right))
15904 {
15905
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 182278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
182278 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
15906 {
15907 }
15908 else
15909 {
15910
2/4
✓ Branch 0 taken 182278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182278 times.
182278 if(charging==0 && spins==0)
15911 {
15912 182278 dir=right;
15913 182278 }
15914
15915 182278 holddir=right;
15916
15917
4/4
✓ Branch 0 taken 13790 times.
✓ Branch 1 taken 168488 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13789 times.
182278 if(DrunkUp()&&shiftdir!=down)
15918 {
15919 13789 shiftdir=up;
15920 13789 }
15921
3/4
✓ Branch 0 taken 10832 times.
✓ Branch 1 taken 157657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10832 times.
168489 else if(DrunkDown()&&shiftdir!=up)
15922 {
15923 10832 shiftdir=down;
15924 10832 }
15925 else
15926 {
15927 157657 shiftdir=-1;
15928 }
15929
15930 //bool walkable;
15931 182278 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15932
15933
2/2
✓ Branch 0 taken 107096 times.
✓ Branch 1 taken 75182 times.
182278 if(y.getInt()&7)
15934 75182 info = info || walkflag(x+15+z3step,y+16,1,right);
15935
15936 182278 execute(info);
15937
15938
2/2
✓ Branch 0 taken 19333 times.
✓ Branch 1 taken 162945 times.
182278 if(info.isUnwalkable())
15939 {
15940
2/2
✓ Branch 0 taken 18921 times.
✓ Branch 1 taken 412 times.
19333 if(z3step==2)
15941 {
15942 18921 z3step=1;
15943 18921 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15944
15945
2/2
✓ Branch 0 taken 9168 times.
✓ Branch 1 taken 9753 times.
18921 if(y.getInt()&7)
15946 9753 info = info || walkflag(x+15+z3step,y+16,1,right);
15947
15948 18921 execute(info);
15949
15950
2/2
✓ Branch 0 taken 18292 times.
✓ Branch 1 taken 629 times.
18921 if(info.isUnwalkable())
15951 {
15952 18292 walkable = false;
15953 18292 }
15954 else
15955 {
15956 629 walkable=true;
15957 }
15958 18921 }
15959 else
15960 {
15961 412 walkable=false;
15962 }
15963 19333 }
15964 else
15965 {
15966 162945 walkable = true;
15967 }
15968
15969 182278 int32_t s=shiftdir;
15970
15971
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 182278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 116352 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
182278 if((isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15972 {
15973 65926 shiftdir=-1;
15974 65926 }
15975 else
15976 {
15977
2/2
✓ Branch 0 taken 104325 times.
✓ Branch 1 taken 12027 times.
116352 if(s==up)
15978 {
15979 12027 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15980 12027 execute(info);
15981
15982
2/2
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 10934 times.
12027 if(info.isUnwalkable())
15983 {
15984 1093 shiftdir=-1;
15985 1093 }
15986
2/2
✓ Branch 0 taken 1361 times.
✓ Branch 1 taken 9573 times.
10934 else if(walkable)
15987 {
15988 9573 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15989 9573 execute(info);
15990
15991
2/2
✓ Branch 0 taken 9559 times.
✓ Branch 1 taken 14 times.
9573 if(info.isUnwalkable())
15992 {
15993 14 shiftdir=-1;
15994 14 }
15995 9573 }
15996 12027 }
15997
2/2
✓ Branch 0 taken 93970 times.
✓ Branch 1 taken 10355 times.
104325 else if(s==down)
15998 {
15999 10355 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16000 10355 execute(info);
16001
16002
2/2
✓ Branch 0 taken 1141 times.
✓ Branch 1 taken 9214 times.
10355 if(info.isUnwalkable())
16003 {
16004 1141 shiftdir=-1;
16005 1141 }
16006
2/2
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 7882 times.
9214 else if(walkable)
16007 {
16008 7882 info = walkflag(x+16,y+16,1,down);
16009 7882 execute(info);
16010
16011
2/2
✓ Branch 0 taken 7863 times.
✓ Branch 1 taken 19 times.
7882 if(info.isUnwalkable())
16012 {
16013 19 shiftdir=-1;
16014 19 }
16015 7882 }
16016 10355 }
16017 }
16018
16019 182278 moveOld2(right);
16020 182278 shiftdir=s;
16021
16022
2/2
✓ Branch 0 taken 163574 times.
✓ Branch 1 taken 18704 times.
182278 if(!walkable)
16023 {
16024
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 15302 times.
18704 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16025 {
16026 15302 int32_t v1=bigHitbox?0:8;
16027 15302 int32_t v2=bigHitbox?8:12;
16028
16029 45906 info = !walkflag(x+16,y+v1,1,right)&&
16030 30604 !walkflag(x+16,y+v2,1,right)&&
16031 15302 walkflag(x+16,y+15,1,right);
16032
16033 //do NOT execute these
16034
2/2
✓ Branch 0 taken 1073 times.
✓ Branch 1 taken 14229 times.
15302 if(info.isUnwalkable())
16035 {
16036
8/12
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 1040 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1040 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1040 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1040 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1072 times.
1073 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16037 1072 sprite::move((zfix)0,(zfix)-1);
16038 1073 }
16039 else
16040 {
16041 42687 info = walkflag(x+16,y+v1, 1,right)&&
16042 28458 !walkflag(x+16,y+v2-1,1,right)&&
16043 14229 !walkflag(x+16,y+15, 1,right);
16044
16045
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 13773 times.
14229 if(info.isUnwalkable())
16046 {
16047
7/12
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 432 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 432 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 456 times.
456 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16048 456 sprite::move((zfix)0,(zfix)1);
16049 456 }
16050 else //if(shiftdir==-1)
16051 {
16052 13773 pushing=push+1;
16053 13773 z3step=2;
16054
16055
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 13707 times.
13773 if(action!=swimming)
16056 {
16057 13707 }
16058 }
16059 }
16060
16061 15302 z3step=2;
16062 15302 }
16063 else
16064 {
16065 3402 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16066
16067
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3392 times.
3402 if(action!=swimming)
16068 {
16069 3392 }
16070
16071 3402 z3step=2;
16072 }
16073 18704 }
16074
16075 182278 return;
16076 }
16077 }
16078 }
16079
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 302246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
302246 if(shield_forcedir > -1 && action != rafting)
16080 dir = shield_forcedir;
16081 302246 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
16082 302246 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
16083 302246 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
16084 302246 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
16085 302246 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
16086
16087
8/12
✓ Branch 0 taken 125155 times.
✓ Branch 1 taken 177091 times.
✓ Branch 2 taken 125155 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 125155 times.
✓ Branch 6 taken 125155 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 122372 times.
✓ Branch 9 taken 2783 times.
✓ Branch 10 taken 122372 times.
✗ Branch 11 not taken.
302246 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
16088 {
16089
8/12
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 121868 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 455 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 455 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 455 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
122372 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
16090 {
16091 //action=swimming;
16092
3/12
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
455 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16093 {
16094 hopclk = 0xFF;
16095 }
16096 455 }
16097 122372 }
16098
16099 302246 return;
16100 } //endif (LTTPWALK)
16101 2522624 temp_step = hero_newstep;
16102 2522624 temp_x = x;
16103 2522624 temp_y = y;
16104
16105
7/8
✓ Branch 0 taken 1507150 times.
✓ Branch 1 taken 1015474 times.
✓ Branch 2 taken 1475745 times.
✓ Branch 3 taken 31405 times.
✓ Branch 4 taken 43770 times.
✓ Branch 5 taken 1463380 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43770 times.
2522624 if(isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam)
16106 {
16107
2/4
✓ Branch 0 taken 43770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43770 times.
43770 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16108 goto LEFTRIGHT_NEWMOVE;
16109 43770 else goto LEFTRIGHT_OLDMOVE;
16110 }
16111
16112 // make it easier to get in left & right doors
16113
16114 //ignore ladder for this part. sigh sigh sigh -DD
16115 2478854 oldladderx = ladderx;
16116 2478854 oldladdery = laddery;
16117
2/4
✓ Branch 0 taken 2478854 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2478854 times.
2478854 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16118 {
16119 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
16120 {
16121 do
16122 {
16123 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16124 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16125
16126 if(info.isUnwalkable())
16127 {
16128 if(temp_x != int32_t(temp_x))
16129 {
16130 temp_x = floor((double)temp_x);
16131 }
16132 else if(temp_step > 1)
16133 {
16134 if(temp_step != int32_t(temp_step)) //floor
16135 temp_step = floor((double)temp_step);
16136 else --temp_step;
16137 }
16138 else
16139 break;
16140 }
16141 }
16142 while(info.isUnwalkable());
16143
16144 if(!info.isUnwalkable())
16145 {
16146 x = temp_x;
16147 y = temp_y;
16148 hero_newstep = temp_step;
16149 //ONLY process the side-effects of the above walkflag if Hero will actually move
16150 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16151 execute(info);
16152 moveOld2(left);
16153 return;
16154 }
16155 temp_x = x;
16156 temp_y = y;
16157 temp_step = hero_newstep;
16158 }
16159
16160 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
16161 {
16162 do
16163 {
16164 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16165 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
16166
16167 if(info.isUnwalkable())
16168 {
16169 if(temp_x != int32_t(temp_x))
16170 {
16171 temp_x = floor((double)temp_x);
16172 }
16173 else if(temp_step > 1)
16174 {
16175 if(temp_step != int32_t(temp_step)) //floor
16176 temp_step = floor((double)temp_step);
16177 else --temp_step;
16178 }
16179 else
16180 break;
16181 }
16182 }
16183 while(info.isUnwalkable());
16184
16185 if(!info.isUnwalkable())
16186 {
16187 x = temp_x;
16188 y = temp_y;
16189 hero_newstep = temp_step;
16190 execute(info);
16191 moveOld2(right);
16192 return;
16193 }
16194 temp_x = x;
16195 temp_y = y;
16196 temp_step = hero_newstep;
16197 }
16198
16199 ladderx = oldladderx;
16200 laddery = oldladdery;
16201
16202 if(DrunkUp())
16203 {
16204 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16205 {
16206 if(dir!=up && dir!=down)
16207 {
16208 if(xoff>2&&xoff<6)
16209 {
16210 moveOld2(dir);
16211 }
16212 else if(xoff>=6)
16213 {
16214 moveOld2(right);
16215 }
16216 else if(xoff>=1)
16217 {
16218 moveOld2(left);
16219 }
16220 }
16221 else
16222 {
16223 if(xoff>=4)
16224 {
16225 moveOld2(right);
16226 }
16227 else if(xoff<4)
16228 {
16229 moveOld2(left);
16230 }
16231 }
16232 }
16233 else
16234 {
16235 do
16236 {
16237 if(action==swimming || IsSideSwim() || action == swimhit)
16238 {
16239 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16240
16241 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
16242 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
16243 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
16244 info.setUnwalkable(true);
16245 }
16246 else
16247 {
16248 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
16249 if(x.getInt() & 7)
16250 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
16251 else
16252 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
16253 }
16254
16255 if(info.isUnwalkable())
16256 {
16257 if(temp_y != int32_t(temp_y))
16258 {
16259 temp_y = floor((double)temp_y);
16260 }
16261 else if(temp_step > 1)
16262 {
16263 if(temp_step != int32_t(temp_step)) //floor
16264 temp_step = floor((double)temp_step);
16265 else --temp_step;
16266 }
16267 else
16268 break;
16269 }
16270 }
16271 while(info.isUnwalkable());
16272
16273 execute(info);
16274
16275 if(!info.isUnwalkable())
16276 {
16277 x = temp_x;
16278 y = temp_y;
16279 hero_newstep = temp_step;
16280 moveOld2(up);
16281 return;
16282 }
16283
16284 if(!DrunkLeft() && !DrunkRight())
16285 {
16286 if(NO_GRIDLOCK)
16287 {
16288 x = x.getInt();
16289 y = y.getInt();
16290 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16291 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16292 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16293 {
16294 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16295 sprite::move((zfix)-1,(zfix)0);
16296 }
16297 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16298 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16299 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16300 {
16301 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16302 sprite::move((zfix)1,(zfix)0);
16303 }
16304 else
16305 {
16306 pushing=push+1;
16307 }
16308 }
16309 else pushing=push+1;
16310
16311 if(charging==0 && spins==0)
16312 {
16313 dir=up;
16314 }
16315
16316 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16317 {
16318 herostep();
16319 }
16320
16321 return;
16322 }
16323 else
16324 {
16325 goto LEFTRIGHT_NEWMOVE;
16326 }
16327 }
16328
16329 return;
16330 }
16331
16332 if(DrunkDown())
16333 {
16334 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16335 {
16336 if(dir!=up && dir!=down)
16337 {
16338 if(xoff>2&&xoff<6)
16339 {
16340 moveOld2(dir);
16341 }
16342 else if(xoff>=6)
16343 {
16344 moveOld2(right);
16345 }
16346 else if(xoff>=1)
16347 {
16348 moveOld2(left);
16349 }
16350 }
16351 else
16352 {
16353 if(xoff>=4)
16354 {
16355 moveOld2(right);
16356 }
16357 else if(xoff<4)
16358 {
16359 moveOld2(left);
16360 }
16361 }
16362 }
16363 else
16364 {
16365 do
16366 {
16367 if(action==swimming || IsSideSwim() || action == swimhit)
16368 {
16369 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16370
16371 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
16372 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
16373 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
16374 info.setUnwalkable(true);
16375 }
16376 else
16377 {
16378 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16379 if(x.getInt() & 7)
16380 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
16381 else
16382 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
16383 }
16384
16385 if(info.isUnwalkable())
16386 {
16387 if(temp_y != int32_t(temp_y))
16388 {
16389 temp_y = floor((double)temp_y);
16390 }
16391 else if(temp_step > 1)
16392 {
16393 if(temp_step != int32_t(temp_step)) //floor
16394 temp_step = floor((double)temp_step);
16395 else --temp_step;
16396 }
16397 else
16398 break;
16399 }
16400 }
16401 while(info.isUnwalkable());
16402
16403 execute(info);
16404
16405 if(!info.isUnwalkable())
16406 {
16407 x = temp_x;
16408 y = temp_y;
16409 hero_newstep = temp_step;
16410 moveOld2(down);
16411 return;
16412 }
16413
16414 if(!DrunkLeft() && !DrunkRight())
16415 {
16416 if(NO_GRIDLOCK)
16417 {
16418 x = x.getInt();
16419 y = y.getInt();
16420 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16421 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16422 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16423 {
16424 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16425 sprite::move((zfix)-1,(zfix)0);
16426 }
16427 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16428 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16429 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16430 {
16431 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16432 sprite::move((zfix)1,(zfix)0);
16433 }
16434 else
16435 {
16436 pushing=push+1;
16437 }
16438 }
16439 else pushing=push+1;
16440
16441 if(charging==0 && spins==0)
16442 {
16443 dir=down;
16444 }
16445
16446 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16447 {
16448 herostep();
16449 }
16450
16451 return;
16452 }
16453 else goto LEFTRIGHT_NEWMOVE;
16454 }
16455
16456 return;
16457 }
16458
16459 LEFTRIGHT_NEWMOVE:
16460 temp_x = x;
16461 temp_y = y;
16462 temp_step = hero_newstep;
16463 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16464 {
16465 return;
16466 }
16467
16468 if(DrunkLeft())
16469 {
16470 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16471 {
16472 if(dir!=left && dir!=right)
16473 {
16474 if(yoff>2&&yoff<6)
16475 {
16476 moveOld2(dir);
16477 }
16478 else if(yoff>=6)
16479 {
16480 moveOld2(down);
16481 }
16482 else if(yoff>=1)
16483 {
16484 moveOld2(up);
16485 }
16486 }
16487 else
16488 {
16489 if(yoff>=4)
16490 {
16491 moveOld2(down);
16492 }
16493 else if(yoff<4)
16494 {
16495 moveOld2(up);
16496 }
16497 }
16498 }
16499 else
16500 {
16501 do
16502 {
16503 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16504 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16505
16506 if(y.getInt() & 7)
16507 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16508
16509 if(info.isUnwalkable())
16510 {
16511 if(temp_x != int32_t(temp_x))
16512 {
16513 temp_x = floor((double)temp_x);
16514 }
16515 else if(temp_step > 1)
16516 {
16517 if(temp_step != int32_t(temp_step)) //floor
16518 temp_step = floor((double)temp_step);
16519 else --temp_step;
16520 }
16521 else
16522 break;
16523 }
16524 }
16525 while(info.isUnwalkable());
16526
16527 execute(info);
16528
16529 if(!info.isUnwalkable())
16530 {
16531 x = temp_x;
16532 y = temp_y;
16533 hero_newstep = temp_step;
16534 moveOld2(left);
16535 return;
16536 }
16537
16538 if(!DrunkUp() && !DrunkDown())
16539 {
16540 if(NO_GRIDLOCK)
16541 {
16542 x = x.getInt();
16543 y = y.getInt();
16544 int32_t v1=bigHitbox?0:8;
16545 int32_t v2=bigHitbox?8:12;
16546
16547 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16548 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16549 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16550 {
16551 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16552 sprite::move((zfix)0,(zfix)-1);
16553 }
16554 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16555 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16556 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16557 {
16558 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16559 sprite::move((zfix)0,(zfix)1);
16560 }
16561 else
16562 {
16563 pushing=push+1;
16564 }
16565 }
16566 else pushing=push+1;
16567
16568 if(charging==0 && spins==0)
16569 {
16570 dir=left;
16571 }
16572
16573 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16574 {
16575 herostep();
16576 }
16577
16578 return;
16579 }
16580 }
16581
16582 return;
16583 }
16584
16585 if(DrunkRight())
16586 {
16587 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16588 {
16589 if(dir!=left && dir!=right)
16590 {
16591 if(yoff>2&&yoff<6)
16592 {
16593 moveOld2(dir);
16594 }
16595 else if(yoff>=6)
16596 {
16597 moveOld2(down);
16598 }
16599 else if(yoff>=1)
16600 {
16601 moveOld2(up);
16602 }
16603 }
16604 else
16605 {
16606 if(yoff>=4)
16607 {
16608 moveOld2(down);
16609 }
16610 else if(yoff<4)
16611 {
16612 moveOld2(up);
16613 }
16614 }
16615 }
16616 else
16617 {
16618 do
16619 {
16620 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16621 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16622
16623 if(y.getInt() & 7)
16624 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16625
16626 if(info.isUnwalkable())
16627 {
16628 if(temp_x != int32_t(temp_x))
16629 {
16630 temp_x = floor((double)temp_x);
16631 }
16632 else if(temp_step > 1)
16633 {
16634 if(temp_step != int32_t(temp_step)) //floor
16635 temp_step = floor((double)temp_step);
16636 else --temp_step;
16637 }
16638 else
16639 break;
16640 }
16641 }
16642 while(info.isUnwalkable());
16643
16644 execute(info);
16645
16646 if(!info.isUnwalkable())
16647 {
16648 x = temp_x;
16649 y = temp_y;
16650 hero_newstep = temp_step;
16651 moveOld2(right);
16652 return;
16653 }
16654
16655 if(!DrunkUp() && !DrunkDown())
16656 {
16657 if(NO_GRIDLOCK)
16658 {
16659 x = x.getInt();
16660 y = y.getInt();
16661 int32_t v1=bigHitbox?0:8;
16662 int32_t v2=bigHitbox?8:12;
16663
16664 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16665 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16666 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16667 {
16668 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16669 sprite::move((zfix)0,(zfix)-1);
16670 }
16671 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16672 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16673 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16674 {
16675 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16676 sprite::move((zfix)0,(zfix)1);
16677 }
16678 else
16679 {
16680 pushing=push+1;
16681 }
16682 }
16683 else pushing=push+1;
16684
16685 if(charging==0 && spins==0)
16686 {
16687 dir=right;
16688 }
16689
16690 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16691 {
16692 herostep();
16693 }
16694
16695 return;
16696 }
16697 }
16698 }
16699 }
16700 else
16701 {
16702 4957708 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16703 2478854 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16704
16705
10/10
✓ Branch 0 taken 1463380 times.
✓ Branch 1 taken 1015474 times.
✓ Branch 2 taken 179673 times.
✓ Branch 3 taken 1283707 times.
✓ Branch 4 taken 103702 times.
✓ Branch 5 taken 75971 times.
✓ Branch 6 taken 930 times.
✓ Branch 7 taken 102772 times.
✓ Branch 8 taken 85 times.
✓ Branch 9 taken 845 times.
2478854 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16706 {
16707 //ONLY process the side-effects of the above walkflag if Hero will actually move
16708 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16709 845 execute(info);
16710 845 moveOld2(left);
16711 845 return;
16712 }
16713
16714 4956018 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16715 2478009 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16716
16717
10/10
✓ Branch 0 taken 1462535 times.
✓ Branch 1 taken 1015474 times.
✓ Branch 2 taken 200357 times.
✓ Branch 3 taken 1262178 times.
✓ Branch 4 taken 112639 times.
✓ Branch 5 taken 87718 times.
✓ Branch 6 taken 1152 times.
✓ Branch 7 taken 111487 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 1063 times.
2478009 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16718 {
16719 1063 execute(info);
16720 1063 moveOld2(right);
16721 1063 return;
16722 }
16723
16724 2476946 ladderx = oldladderx;
16725 2476946 laddery = oldladdery;
16726
16727
2/2
✓ Branch 0 taken 270673 times.
✓ Branch 1 taken 2206273 times.
2476946 if(DrunkUp())
16728 {
16729
11/14
✓ Branch 0 taken 7171 times.
✓ Branch 1 taken 263502 times.
✓ Branch 2 taken 6708 times.
✓ Branch 3 taken 463 times.
✓ Branch 4 taken 5682 times.
✓ Branch 5 taken 1026 times.
✓ Branch 6 taken 5682 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5682 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5682 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 5679 times.
270673 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16730 {
16731
3/4
✓ Branch 0 taken 5646 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5646 times.
5679 if(dir!=up && dir!=down)
16732 {
16733
4/4
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 1738 times.
✓ Branch 2 taken 1675 times.
✓ Branch 3 taken 2233 times.
5646 if(xoff>2&&xoff<6)
16734 {
16735 2233 moveOld2(dir);
16736 2233 }
16737
2/2
✓ Branch 0 taken 1675 times.
✓ Branch 1 taken 1738 times.
3413 else if(xoff>=6)
16738 {
16739 1675 moveOld2(right);
16740 1675 }
16741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1738 times.
1738 else if(xoff>=1)
16742 {
16743 1738 moveOld2(left);
16744 1738 }
16745 5646 }
16746 else
16747 {
16748
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16749 {
16750 10 moveOld2(right);
16751 10 }
16752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16753 {
16754 23 moveOld2(left);
16755 23 }
16756 }
16757 5679 }
16758 else
16759 {
16760
4/6
✓ Branch 0 taken 253608 times.
✓ Branch 1 taken 11386 times.
✓ Branch 2 taken 253608 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 253608 times.
264994 if(action==swimming || IsSideSwim() || action == swimhit)
16761 {
16762 11386 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16763
16764
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11386 times.
✓ Branch 4 taken 944 times.
✓ Branch 5 taken 10442 times.
✓ Branch 6 taken 8870 times.
✓ Branch 7 taken 2516 times.
21828 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16765
2/2
✓ Branch 0 taken 2488 times.
✓ Branch 1 taken 7954 times.
18396 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16766 7954 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16767 2516 info.setUnwalkable(true);
16768 11386 }
16769 else
16770 {
16771 253608 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16772
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 253141 times.
253608 if(x.getInt() & 7)
16773 467 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16774 else
16775 253141 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16776 }
16777
16778 264994 execute(info);
16779
16780
2/2
✓ Branch 0 taken 116212 times.
✓ Branch 1 taken 148782 times.
264994 if(!info.isUnwalkable())
16781 {
16782 148782 moveOld2(up);
16783 148782 return;
16784 }
16785
16786
4/4
✓ Branch 0 taken 104529 times.
✓ Branch 1 taken 11683 times.
✓ Branch 2 taken 11713 times.
✓ Branch 3 taken 92816 times.
116212 if(!DrunkLeft() && !DrunkRight())
16787 {
16788
2/4
✓ Branch 0 taken 92816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 92816 times.
92816 if(NO_GRIDLOCK)
16789 {
16790 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16791 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16792 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16793 {
16794 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16795 sprite::move((zfix)-1,(zfix)0);
16796 }
16797 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16798 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16799 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16800 {
16801 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16802 sprite::move((zfix)1,(zfix)0);
16803 }
16804 else
16805 {
16806 pushing=push+1;
16807 }
16808 }
16809 92816 else pushing=push+1;
16810
16811
4/4
✓ Branch 0 taken 92633 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 92537 times.
92816 if(charging==0 && spins==0)
16812 {
16813 92537 dir=up;
16814 92537 }
16815
16816
5/8
✓ Branch 0 taken 90916 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 90916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90916 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90916 times.
92816 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16817 {
16818 90916 herostep();
16819 90916 }
16820
16821 92816 return;
16822 }
16823 else
16824 {
16825 23396 goto LEFTRIGHT_OLDMOVE;
16826 }
16827 }
16828
16829 5679 return;
16830 }
16831
16832
2/2
✓ Branch 0 taken 239808 times.
✓ Branch 1 taken 1966465 times.
2206273 if(DrunkDown())
16833 {
16834
11/14
✓ Branch 0 taken 6755 times.
✓ Branch 1 taken 233053 times.
✓ Branch 2 taken 6478 times.
✓ Branch 3 taken 277 times.
✓ Branch 4 taken 4443 times.
✓ Branch 5 taken 2035 times.
✓ Branch 6 taken 4443 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4443 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4443 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 4442 times.
239808 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16835 {
16836
3/4
✓ Branch 0 taken 4442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4441 times.
4442 if(dir!=up && dir!=down)
16837 {
16838
4/4
✓ Branch 0 taken 3116 times.
✓ Branch 1 taken 1325 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 1790 times.
4441 if(xoff>2&&xoff<6)
16839 {
16840 1790 moveOld2(dir);
16841 1790 }
16842
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 1325 times.
2651 else if(xoff>=6)
16843 {
16844 1326 moveOld2(right);
16845 1326 }
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1325 times.
1325 else if(xoff>=1)
16847 {
16848 1325 moveOld2(left);
16849 1325 }
16850 4441 }
16851 else
16852 {
16853
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16854 {
16855 1 moveOld2(right);
16856 1 }
16857 else if(xoff<4)
16858 {
16859 moveOld2(left);
16860 }
16861 }
16862 4442 }
16863 else
16864 {
16865
4/6
✓ Branch 0 taken 222802 times.
✓ Branch 1 taken 12564 times.
✓ Branch 2 taken 222802 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 222802 times.
235366 if(action==swimming || IsSideSwim() || action == swimhit)
16866 {
16867 12564 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16868
16869
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12564 times.
✓ Branch 4 taken 893 times.
✓ Branch 5 taken 11671 times.
✓ Branch 6 taken 8139 times.
✓ Branch 7 taken 4425 times.
24235 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16870
2/2
✓ Branch 0 taken 4353 times.
✓ Branch 1 taken 7318 times.
18989 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16871 7318 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16872 4425 info.setUnwalkable(true);
16873 12564 }
16874 else
16875 {
16876 222802 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16877
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 222523 times.
222802 if(x.getInt() & 7)
16878 279 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16879 else
16880 222523 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16881 }
16882
16883 235366 execute(info);
16884
16885
2/2
✓ Branch 0 taken 111510 times.
✓ Branch 1 taken 123856 times.
235366 if(!info.isUnwalkable())
16886 {
16887 123856 moveOld2(down);
16888 123856 return;
16889 }
16890
16891
4/4
✓ Branch 0 taken 98939 times.
✓ Branch 1 taken 12571 times.
✓ Branch 2 taken 12184 times.
✓ Branch 3 taken 86755 times.
111510 if(!DrunkLeft() && !DrunkRight())
16892 {
16893
2/4
✓ Branch 0 taken 86755 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 86755 times.
86755 if(NO_GRIDLOCK)
16894 {
16895 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16896 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16897 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16898 {
16899 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16900 sprite::move((zfix)-1,(zfix)0);
16901 }
16902 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16903 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16904 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16905 {
16906 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16907 sprite::move((zfix)1,(zfix)0);
16908 }
16909 else
16910 {
16911 pushing=push+1;
16912 }
16913 }
16914 86755 else pushing=push+1;
16915
16916
2/4
✓ Branch 0 taken 86755 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 86755 times.
86755 if(charging==0 && spins==0)
16917 {
16918 86755 dir=down;
16919 86755 }
16920
16921
5/8
✓ Branch 0 taken 84787 times.
✓ Branch 1 taken 1968 times.
✓ Branch 2 taken 84787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84787 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 84787 times.
86755 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16922 {
16923 84787 herostep();
16924 84787 }
16925
16926 86755 return;
16927 }
16928 24755 else goto LEFTRIGHT_OLDMOVE;
16929 }
16930
16931 4442 return;
16932 }
16933
16934 LEFTRIGHT_OLDMOVE:
16935
16936
7/8
✓ Branch 0 taken 1226330 times.
✓ Branch 1 taken 832056 times.
✓ Branch 2 taken 1190609 times.
✓ Branch 3 taken 35721 times.
✓ Branch 4 taken 44836 times.
✓ Branch 5 taken 1181494 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 44836 times.
2058386 if(isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam)
16937 {
16938 44836 return;
16939 }
16940
16941
2/2
✓ Branch 0 taken 304925 times.
✓ Branch 1 taken 1708625 times.
2013550 if(DrunkLeft())
16942 {
16943
11/14
✓ Branch 0 taken 5203 times.
✓ Branch 1 taken 299722 times.
✓ Branch 2 taken 5160 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 4889 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 4889 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4889 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4889 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 4887 times.
304925 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16944 {
16945
3/4
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4882 times.
4887 if(dir!=left && dir!=right)
16946 {
16947
4/4
✓ Branch 0 taken 3480 times.
✓ Branch 1 taken 1402 times.
✓ Branch 2 taken 1492 times.
✓ Branch 3 taken 1988 times.
4882 if(yoff>2&&yoff<6)
16948 {
16949 1988 moveOld2(dir);
16950 1988 }
16951
2/2
✓ Branch 0 taken 1492 times.
✓ Branch 1 taken 1402 times.
2894 else if(yoff>=6)
16952 {
16953 1492 moveOld2(down);
16954 1492 }
16955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1402 times.
1402 else if(yoff>=1)
16956 {
16957 1402 moveOld2(up);
16958 1402 }
16959 4882 }
16960 else
16961 {
16962
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16963 {
16964 5 moveOld2(down);
16965 5 }
16966 else if(yoff<4)
16967 {
16968 moveOld2(up);
16969 }
16970 }
16971 4887 }
16972 else
16973 {
16974 600076 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16975 300038 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16976
16977 300038 execute(info);
16978
16979
2/2
✓ Branch 0 taken 116867 times.
✓ Branch 1 taken 183171 times.
300038 if(!info.isUnwalkable())
16980 {
16981 183171 moveOld2(left);
16982 183171 return;
16983 }
16984
16985
4/4
✓ Branch 0 taken 111132 times.
✓ Branch 1 taken 5735 times.
✓ Branch 2 taken 6269 times.
✓ Branch 3 taken 104863 times.
116867 if(!DrunkUp() && !DrunkDown())
16986 {
16987
2/4
✓ Branch 0 taken 104863 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104863 times.
104863 if(NO_GRIDLOCK)
16988 {
16989 int32_t v1=bigHitbox?0:8;
16990 int32_t v2=bigHitbox?8:12;
16991
16992 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16993 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16994 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16995 {
16996 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16997 sprite::move((zfix)0,(zfix)-1);
16998 }
16999 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
17000 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
17001 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
17002 {
17003 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17004 sprite::move((zfix)0,(zfix)1);
17005 }
17006 else
17007 {
17008 pushing=push+1;
17009 }
17010 }
17011 104863 else pushing=push+1;
17012
17013
3/4
✓ Branch 0 taken 104857 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104857 times.
104863 if(charging==0 && spins==0)
17014 {
17015 104857 dir=left;
17016 104857 }
17017
17018
5/8
✓ Branch 0 taken 101882 times.
✓ Branch 1 taken 2981 times.
✓ Branch 2 taken 101882 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101882 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 101882 times.
104863 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17019 {
17020 101882 herostep();
17021 101882 }
17022
17023 104863 return;
17024 }
17025 }
17026
17027 16891 return;
17028 }
17029
17030
2/2
✓ Branch 0 taken 1381589 times.
✓ Branch 1 taken 327036 times.
1708625 if(DrunkRight())
17031 {
17032
10/14
✓ Branch 0 taken 5175 times.
✓ Branch 1 taken 321861 times.
✓ Branch 2 taken 5039 times.
✓ Branch 3 taken 136 times.
✓ Branch 4 taken 4934 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 4934 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4934 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4934 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4934 times.
327036 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17033 {
17034
4/4
✓ Branch 0 taken 4931 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4927 times.
4934 if(dir!=left && dir!=right)
17035 {
17036
4/4
✓ Branch 0 taken 3508 times.
✓ Branch 1 taken 1419 times.
✓ Branch 2 taken 1494 times.
✓ Branch 3 taken 2014 times.
4927 if(yoff>2&&yoff<6)
17037 {
17038 2014 moveOld2(dir);
17039 2014 }
17040
2/2
✓ Branch 0 taken 1494 times.
✓ Branch 1 taken 1419 times.
2913 else if(yoff>=6)
17041 {
17042 1494 moveOld2(down);
17043 1494 }
17044
1/2
✓ Branch 0 taken 1419 times.
✗ Branch 1 not taken.
1419 else if(yoff>=1)
17045 {
17046 1419 moveOld2(up);
17047 1419 }
17048 4927 }
17049 else
17050 {
17051
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
7 if(yoff>=4)
17052 {
17053 2 moveOld2(down);
17054 2 }
17055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
17056 {
17057 5 moveOld2(up);
17058 5 }
17059 }
17060 4934 }
17061 else
17062 {
17063 644204 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
17064 322102 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
17065
17066 322102 execute(info);
17067
17068
2/2
✓ Branch 0 taken 126406 times.
✓ Branch 1 taken 195696 times.
322102 if(!info.isUnwalkable())
17069 {
17070 195696 moveOld2(right);
17071 195696 return;
17072 }
17073
17074
4/4
✓ Branch 0 taken 121588 times.
✓ Branch 1 taken 4818 times.
✓ Branch 2 taken 5353 times.
✓ Branch 3 taken 116235 times.
126406 if(!DrunkUp() && !DrunkDown())
17075 {
17076
2/4
✓ Branch 0 taken 116235 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116235 times.
116235 if(NO_GRIDLOCK)
17077 {
17078 int32_t v1=bigHitbox?0:8;
17079 int32_t v2=bigHitbox?8:12;
17080
17081 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17082 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
17083 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17084 {
17085 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17086 sprite::move((zfix)0,(zfix)-1);
17087 }
17088 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
17089 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
17090 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
17091 {
17092 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17093 sprite::move((zfix)0,(zfix)1);
17094 }
17095 else
17096 {
17097 pushing=push+1;
17098 }
17099 }
17100 116235 else pushing=push+1;
17101
17102
2/4
✓ Branch 0 taken 116235 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116235 times.
116235 if(charging==0 && spins==0)
17103 {
17104 116235 dir=right;
17105 116235 }
17106
17107
5/8
✓ Branch 0 taken 115260 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 115260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115260 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 115260 times.
116235 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17108 {
17109 115260 herostep();
17110 115260 }
17111
17112 116235 return;
17113 }
17114 }
17115 15105 }
17116 }
17117 6960981 }
17118
17119 8517 bool HeroClass::scr_walkflag(int dx,int dy,int d2,bool kb)
17120 {
17121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
8517 if(toogam) return false;
17122
17123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8517 if(blockpath && dy<80) //Blocked top parts of rooms
17124 return true;
17125
17126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8517 if(blockmoving && mblock2.hit(dx,dy,0,1,1,1))
17127 return true;
17128 //collide_object handled in scr_canmove
17129
17130
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8517 times.
8517 if(isdungeon() && currscr<128 && dy<40
17131 && ((x<=112||x>=128) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17132 && !get_qr(qr_FREEFORM))
17133 return true; //Old NES dungeon stuff
17134
17135
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8517 times.
8517 bool solid = _walkflag(dx,dy,1,SWITCHBLOCK_STATE);
17136
17137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8517 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
17138 {
17139 if(dx>=112&&dx<120&&dy<40&&dy>=32)
17140 solid=true;
17141
17142 if(dx>=136&&dx<144&&dy<40&&dy>=32)
17143 solid=true;
17144 }
17145
17146
2/4
✓ Branch 0 taken 8517 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8517 times.
8517 if(action==swimming || IsSideSwim())
17147 {
17148 if(!solid)
17149 {
17150 bool isthissolid = false;
17151 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17152 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17153 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17154 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17155 isthissolid = true;
17156 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17157
17158 int ls = 22;
17159 if((get_qr(qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_qr(qr_NO_HOPPING))
17160 ls = 1;
17161 if(landswim < ls)
17162 {
17163 if(dx<0||dy<0);
17164 else if(dx>=256);
17165 else if(dy>=176);
17166 else if(get_qr(qr_DROWN) && !ilswim);
17167 else if(iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17168 solid = false;
17169 else
17170 solid = true;
17171 }
17172 }
17173 else
17174 {
17175 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
17176
17177 if(wtrx)
17178 solid = false;
17179 }
17180 }
17181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
8517 else if(ladderx+laddery) // ladder is being used
17182 {
17183 int32_t lx = zfix(dx);
17184 int32_t ly = zfix(dy);
17185
17186 if(ladderdir<=down) //vertical ladder
17187 {
17188 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17189 {
17190 bool temp = false;
17191
17192 if(!(abs(lx-(ladderx+8))<=8))
17193 temp = true;
17194
17195 if(!temp)
17196 {
17197 solid = false;
17198 }
17199 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17200 {
17201 solid = true;
17202 }
17203 }
17204 }
17205 else //horizontal ladder
17206 {
17207 if(abs(lx-(ladderx+8))<=8)
17208 {
17209 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17210 {
17211 solid = false;
17212 }
17213 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17214 {
17215 solid = true;
17216 }
17217 else if((abs(ly-laddery+8)<=8) && d2<=down)
17218 {
17219 solid = false;
17220 }
17221 }
17222 }
17223 }
17224
3/6
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 8194 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8517 else if(solid || isSideViewHero() || get_qr(qr_DROWN))
17225 {
17226 // see if it's a good spot for the ladder or for swimming
17227
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8517 times.
8517 bool unwalkablex = _walkflag(dx,dy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17228
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
8517 if(get_qr(qr_DROWN))
17230 {
17231 // Drowning changes the following attributes:
17232 // * Dangerous water is also walkable, so ignore the previous
17233 // definitions of unwalkablex.
17234 // * Instead, prevent the ladder from being used in the
17235 // one frame where Hero has landed on water before drowning.
17236 8517 unwalkablex = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17237 8517 }
17238
17239 // check if he can swim
17240
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8517 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8517 if(current_item(itype_flippers) && z==0 && fakez==0)
17241 {
17242 int32_t wtrx = iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy);
17243 if (current_item(itype_flippers) >= combobuf[wtrx].attribytes[0] && (!(combobuf[wtrx].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17244 {
17245 //ladder ignores water combos that are now walkable thanks to flippers -DD
17246 unwalkablex = unwalkablex && (!wtrx);
17247
17248 if(landswim >= 22)
17249 {
17250 solid = false;
17251 }
17252 else if(wtrx)
17253 {
17254 if(dir==d2)
17255 {
17256 ladderx = 0;
17257 laddery = 0;
17258 }
17259 }
17260 }
17261 }
17262
17263 // check if he can use the ladder
17264 // "Allow Ladder Anywhere" is toggled by fLADDER
17265
1/2
✓ Branch 0 taken 8517 times.
✗ Branch 1 not taken.
8517 if(can_deploy_ladder())
17266 // laddersetup
17267 {
17268 // Check if there's water to use the ladder over
17269 bool wtrx = (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy) != 0);
17270 int32_t ldrid = current_item_id(itype_ladder);
17271 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17272
17273 if(wtrx)
17274 {
17275 if(isSideViewHero())
17276 {
17277 wtrx = !_walkflag(dx, dy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(dx, dy, 1,SWITCHBLOCK_STATE) && dir!=down;
17278 }
17279 // * walk on half-water using the ladder instead of using flippers.
17280 // * otherwise, walk on ladder(+hookshot) combos.
17281 else if((isstepable(MAPCOMBO(dx, dy)) || wtrx==true))
17282 {
17283 if(!get_qr(qr_OLD_210_WATER))
17284 {
17285 //if Hero could swim on a tile instead of using the ladder,
17286 //refuse to use the ladder to step over that tile. -DD
17287 wtrx = isstepable(MAPCOMBO(dx, dy)) && unwalkablex;
17288 }
17289 }
17290 }
17291 else
17292 {
17293 // No water; check other things
17294
17295 //Check pits
17296 if(ladderpits)
17297 {
17298 int32_t pit_cmb = getpitfall(dx,dy);
17299 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17300 }
17301 if(!ladderpits || (!wtrx || isSideViewHero())) //If no pit, check ladder combos
17302 {
17303 int32_t combo=combobuf[MAPCOMBO(dx, dy)].type;
17304 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17305 }
17306 }
17307
17308 for (int32_t i = 0; i <= 1; ++i)
17309 {
17310 if(tmpscr2[i].valid!=0)
17311 {
17312 if (get_qr(qr_OLD_BRIDGE_COMBOS))
17313 {
17314 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && !_walkflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
17315 }
17316 else
17317 {
17318 if (combobuf[MAPCOMBO2(i,dx,dy)].type == cBRIDGE && _effectflag_layer(dx,dy,1, &(tmpscr2[i]))) wtrx = false;
17319 }
17320 }
17321 }
17322 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx,dy));
17323
17324 if(d2==dir)
17325 {
17326 int32_t c = walkwater ? 0:8;
17327 int32_t b = walkwater ? 8:0;
17328
17329 if(d2>=left)
17330 {
17331 // If the difference between dy and y is small enough
17332 if(abs((dy)-(int32_t(y+c)))<=(b) && wtrx)
17333 {
17334 // Don't activate the ladder if it would be entirely
17335 // over water and Hero has the flippers. This isn't
17336 // a good way to do this, but it's too risky
17337 // to make big changes to this stuff.
17338 bool deployLadder=true;
17339 int32_t lx=dx&0xF0;
17340 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17341 {
17342 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17343 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17344 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17345 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17346 deployLadder=false;
17347 }
17348 if(deployLadder)
17349 {
17350 ladderx = dx&0xF0;
17351 laddery = y;
17352 ladderdir = left;
17353 ladderstart = d2;
17354 solid = laddery!=y.getInt();
17355 }
17356 }
17357 }
17358 else if(d2<=down)
17359 {
17360 // If the difference between dx and x is small enough
17361 if(abs((dx)-(int32_t(x+c)))<=(b) && wtrx)
17362 {
17363 ladderx = x;
17364 laddery = dy&0xF0;
17365 ladderdir = up;
17366 ladderstart = d2;
17367 solid = ladderx!=x.getInt();
17368 }
17369 }
17370 }
17371 }
17372 8517 }
17373
17374 8517 return solid;
17375 8517 }
17376
17377 8194 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv)
17378 {
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8194 times.
8194 if(toogam) return true;
17380
2/4
✓ Branch 0 taken 8194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8194 times.
✗ Branch 3 not taken.
8194 if(!(dx || dy)) return true;
17381 8194 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
17382 8194 zfix rx = x+15, ry = y+15; //right/bottom
17383 8194 zfix wid = 16, hei = bigHitbox ? 16 : 8;
17384
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 8194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
8194 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17385 return false;
17386
17387 8194 bool nosolid = true;
17388
17389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8194 if(dx && !dy)
17390 {
17391 if(dx < 0)
17392 {
17393 int mx = (bx+dx).getFloor();
17394 for(zfix ty = 0; by+ty < ry; ty += 8)
17395 {
17396 if(scr_walkflag(mx, by+ty, left, kb))
17397 return false;
17398 }
17399 if(scr_walkflag(mx, ry, left, kb))
17400 return false;
17401 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
17402 return false;
17403 }
17404 else
17405 {
17406 int mx = (rx+dx).getCeil();
17407 int lx = mx-hit_width+1;
17408 for(zfix ty = 0; by+ty < ry; ty += 8)
17409 {
17410 if(scr_walkflag(mx, by+ty, right, kb))
17411 return false;
17412 }
17413 if(scr_walkflag(mx, ry, right, kb))
17414 return false;
17415 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
17416 return false;
17417 }
17418 }
17419
2/4
✓ Branch 0 taken 8194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8194 times.
8194 else if(dy && !dx)
17420 {
17421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8194 times.
8194 if(dy < 0)
17422 {
17423 int my = (by+dy).getFloor();
17424 for(zfix tx = 0; bx+tx < rx; tx += 8)
17425 {
17426 if(scr_walkflag(bx+tx, my, up, kb))
17427 return false;
17428 }
17429 if(scr_walkflag(rx, my, up, kb))
17430 return false;
17431 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
17432 return false;
17433 }
17434 else
17435 {
17436 8194 int my = (ry+dy).getCeil();
17437 8194 int ly = my-hit_height+1;
17438
1/2
✓ Branch 0 taken 8517 times.
✗ Branch 1 not taken.
8517 for(zfix tx = 0; bx+tx < rx; tx += 8)
17439 {
17440
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 8194 times.
8517 if(scr_walkflag(bx+tx, my, down, kb))
17441 8194 return false;
17442 323 }
17443 if(scr_walkflag(rx, my, down, kb))
17444 return false;
17445 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
17446 return false;
17447 }
17448 }
17449 else //! Untested, and currently unused.
17450 {
17451 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
17452 }
17453 return true;
17454 8194 }
17455 bool handle_movestate(std::function<bool()> proc)
17456 {
17457 zfix ox = Hero.x, oy = Hero.y;
17458 auto oladderx = Hero.ladderx;
17459 auto oladdery = Hero.laddery;
17460 auto oladderdir = Hero.ladderdir;
17461 auto oladderstart = Hero.ladderstart;
17462
17463 bool ret = proc();
17464
17465 Hero.x = ox;
17466 Hero.y = oy;
17467 Hero.ladderx = oladderx;
17468 Hero.laddery = oladdery;
17469 Hero.ladderdir = oladderdir;
17470 Hero.ladderstart = oladderstart;
17471
17472 return ret;
17473 }
17474
17475 zfix handle_movestate_zfix(std::function<zfix()> proc)
17476 {
17477 zfix ox = Hero.x, oy = Hero.y;
17478 auto oladderx = Hero.ladderx;
17479 auto oladdery = Hero.laddery;
17480 auto oladderdir = Hero.ladderdir;
17481 auto oladderstart = Hero.ladderstart;
17482
17483 zfix ret = proc();
17484
17485 Hero.x = ox;
17486 Hero.y = oy;
17487 Hero.ladderx = oladderx;
17488 Hero.laddery = oladdery;
17489 Hero.ladderdir = oladderdir;
17490 Hero.ladderstart = oladderstart;
17491
17492 return ret;
17493 }
17494 482 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
17495 {
17496 482 bool ret = true;
17497
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
482 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
17498
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(sv)
17499 dy = 0;
17500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
482 if(dx && dy)
17501 shove = false;
17502 482 bool checkladder = dy < 0;
17503
17504 482 const int scl = 2;
17505
2/4
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 482 times.
482 while(abs(dx) > scl || abs(dy) > scl)
17506 {
17507 if(abs(dx) > abs(dy))
17508 {
17509 int32_t tdx = dx.sign() * scl;
17510 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
17511 dx -= tdx;
17512 else
17513 {
17514 if(earlyret) return false;
17515 dx = tdx;
17516 ret = false;
17517 }
17518 }
17519 else
17520 {
17521 int32_t tdy = dy.sign() * scl;
17522 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
17523 dy -= tdy;
17524 else
17525 {
17526 if(earlyret) return false;
17527 dy = tdy;
17528 ret = false;
17529 }
17530 }
17531 }
17532
17533
6/12
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 482 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 482 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 482 times.
✓ Branch 8 taken 482 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 482 times.
482 bool skipdmg = earlyret || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS));
17534
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(dx)
17535 {
17536 if(scr_canmove(dx, 0, kb, ign_sv))
17537 x += dx;
17538 else
17539 {
17540 bool stopped = true;
17541 if(shove)
17542 {
17543 zfix tx = (dx < 0 ? (x-1) : (x+16));
17544 auto mdir = GET_XDIR(dx);
17545 int v1=bigHitbox?0:8;
17546 int v2=bigHitbox?8:12;
17547 bool hit_top = scr_walkflag(tx,y+v1,mdir,false);
17548 bool hit_mid = scr_walkflag(tx,y+v2,mdir,false);
17549 bool hit_bottom = scr_walkflag(tx,y+15,mdir,false);
17550 if(!hit_mid && (hit_top!=hit_bottom))
17551 {
17552 if(hit_bottom) //shove up
17553 {
17554 if(skipdmg || !checkdamagecombos(tx,get_qr(qr_SENSITIVE_SOLID_DAMAGE)?int32_t(y+15):(v1+bigHitbox?11:4)))
17555 movexy(0, -1, kb, true, false, false);
17556 }
17557 else //shove down
17558 {
17559 if(skipdmg || !checkdamagecombos(tx,v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17560 movexy(0, 1, kb, true, false, false);
17561 }
17562
17563 if(scr_canmove(dx, 0, kb, ign_sv))
17564 {
17565 x += dx;
17566 stopped = false;
17567 }
17568 }
17569 }
17570 if(stopped)
17571 {
17572 ret = false;
17573 int xsign = dx.sign();
17574 while(scr_canmove(xsign, 0, kb, ign_sv))
17575 {
17576 x += xsign;
17577 dx -= xsign;
17578 }
17579 if(dx)
17580 {
17581 dx.doDecBound(0,-9999, 0,9999);
17582 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
17583 if(scr_canmove(val, 0, kb, ign_sv))
17584 {
17585 retval = val;
17586 return BSEARCH_CONTINUE_AWAY0;
17587 }
17588 else return BSEARCH_CONTINUE_TOWARD0;
17589 });
17590 x += dx;
17591 }
17592 }
17593 }
17594 }
17595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(dy)
17596 {
17597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(scr_canmove(0, dy, kb, ign_sv))
17598 y += dy;
17599 else
17600 {
17601 482 bool stopped = true;
17602
1/2
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
482 if(shove)
17603 {
17604 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-1) : (y+16));
17605 auto mdir = GET_YDIR(dy);
17606 bool hit_left = scr_walkflag(x,ty,mdir,false);
17607 bool hit_mid = scr_walkflag(x+8,ty,mdir,false);
17608 bool hit_right = scr_walkflag(x+15,ty,mdir,false);
17609 if(!hit_mid && (hit_left!=hit_right))
17610 {
17611 if(hit_right) //shove left
17612 {
17613 if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),ty))
17614 movexy(-1, 0, kb, true, false, false);
17615 }
17616 else //shove right
17617 {
17618 if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),ty))
17619 movexy(1, 0, kb, true, false, false);
17620 }
17621
17622 if(scr_canmove(0, dy, kb, ign_sv))
17623 {
17624 y += dy;
17625 stopped = false;
17626 }
17627 }
17628 }
17629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(stopped)
17630 {
17631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(earlyret) return false;
17632 482 ret = false;
17633 482 int ysign = dy.sign();
17634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 while(scr_canmove(0, ysign, kb, ign_sv))
17635 {
17636 y += ysign;
17637 dy -= ysign;
17638 }
17639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(dy)
17640 {
17641 482 dy.doDecBound(0,-9999, 0,9999);
17642
3/6
✓ Branch 0 taken 482 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 482 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 482 times.
✗ Branch 5 not taken.
7712 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
17643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7230 times.
7230 if(scr_canmove(0, val, kb, ign_sv))
17644 {
17645 retval = val;
17646 return BSEARCH_CONTINUE_AWAY0;
17647 }
17648 7230 else return BSEARCH_CONTINUE_TOWARD0;
17649 7230 });
17650 482 y += dy;
17651 482 }
17652 482 }
17653 }
17654 482 }
17655
17656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
482 if(earlyret)
17657 return ret;
17658 482 WalkflagInfo info;
17659 482 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
17660 482 execute(info);
17661
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
482 if(!ign_sv && sideview_mode() && IsSideSwim() && checkladder)
17662 {
17663 if(!iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)), currmap, currscr, -1, x, y+(bigHitbox?0:8) - 2, true, false)
17664 && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y+(bigHitbox?0:8) - 4) > 0)
17665 {
17666 if (game->get_sideswim_jump() != 0)
17667 {
17668 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
17669 sfx(WAV_ZN1SPLASH,(int32_t)x);
17670 hopclk = 0;
17671 if (charging || spins) action = attacking;
17672 else action = none;
17673 }
17674 else
17675 {
17676 movexy(0,-1*dy,false,false,false);
17677 }
17678 }
17679 }
17680 482 return ret;
17681 482 }
17682 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
17683 {
17684 return handle_movestate([&]()
17685 {
17686 return movexy(dx,dy,kb,ign_sv,shove,true);
17687 });
17688 }
17689 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
17690 {
17691 double v = degrees.getFloat() * PI / 180.0;
17692 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
17693 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
17694 }
17695 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
17696 {
17697 return handle_movestate([&]()
17698 {
17699 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
17700 });
17701 }
17702 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
17703 {
17704 static const zfix diagrate = zslongToFix(7071);
17705 switch(NORMAL_DIR(dir))
17706 {
17707 case up:
17708 return movexy(0, -px, kb, ign_sv, shove, earlyret);
17709 case down:
17710 return movexy(0, px, kb, ign_sv, shove, earlyret);
17711 case left:
17712 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
17713 case right:
17714 return movexy(px, 0, kb, ign_sv, shove, earlyret);
17715 case r_up:
17716 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
17717 case r_down:
17718 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
17719 case l_up:
17720 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
17721 case l_down:
17722 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
17723 }
17724 return false;
17725 }
17726 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
17727 {
17728 return handle_movestate([&]()
17729 {
17730 return moveDir(dir,px,kb,ign_sv,shove,true);
17731 });
17732 }
17733
17734
17735 bool HeroClass::premove()
17736 {
17737 if(lstunclock) return false;
17738 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
17739 int32_t xoff=x.getInt()&7;
17740 int32_t yoff=y.getInt()&7;
17741 if(NO_GRIDLOCK)
17742 {
17743 xoff = 0;
17744 yoff = 0;
17745 }
17746 int32_t push=pushing;
17747 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
17748 int32_t flippers_id = current_item_id(itype_flippers);
17749 itemdata const& itm = itemsbuf[flippers_id];
17750 byte intbtn = byte(itm.misc3&0xFF);
17751 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
17752 bool eatdive = false;
17753 if(diveclk>0)
17754 {
17755 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
17756 --diveclk;
17757 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
17758 {
17759 diveclk = itemsbuf[flippers_id].misc2;
17760 eatdive = true;
17761 }
17762 }
17763 else if(action == swimming && dive_pressed)
17764 {
17765 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
17766 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
17767
17768 if(global_diving==screen_diving)
17769 {
17770 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
17771 eatdive = true;
17772 }
17773 }
17774 if(eatdive)
17775 getIntBtnInput(intbtn, true, true, false, false, false);
17776
17777 if(action==rafting)
17778 {
17779 do_rafting();
17780
17781 if(action==rafting)
17782 {
17783 return false;
17784 }
17785
17786
17787 set_respawn_point();
17788 trySideviewLadder();
17789 }
17790
17791 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
17792 int32_t btnwpn = -1;
17793
17794 //&0xFFF removes the "bow & arrows" bitmask
17795 //The Quick Sword is allowed to interrupt attacks.
17796 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
17797 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
17798 {
17799 if(DrunkrBbtn())
17800 {
17801 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
17802 dowpn = Bwpn&0xFFF;
17803 directWpn = directItemB;
17804 }
17805 else if(DrunkrAbtn())
17806 {
17807 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
17808 dowpn = Awpn&0xFFF;
17809 directWpn = directItemA;
17810 }
17811 else if(get_qr(qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
17812 {
17813 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
17814 dowpn = Xwpn&0xFFF;
17815 directWpn = directItemX;
17816 }
17817 else if(get_qr(qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
17818 {
17819 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
17820 dowpn = Ywpn&0xFFF;
17821 directWpn = directItemY;
17822 }
17823
17824 if(directWpn > 255) directWpn = 0;
17825
17826 // The Quick Sword only allows repeated sword or wand swings.
17827 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
17828 btnwpn=-1;
17829 }
17830
17831 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
17832 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
17833 {
17834 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
17835 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
17836 {
17837 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
17838 {
17839 paymagiccost(attackid,true);
17840 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
17841 }
17842 SetAttack();
17843 attack=wSword;
17844
17845 attackclk=0;
17846 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
17847
17848 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
17849 {
17850 if(!checkmagiccost(dowpn))
17851 {
17852 item_error();
17853 }
17854 else
17855 {
17856 //clear the item script stack for a new script
17857 int i = dowpn;
17858 FFCore.reset_script_engine_data(ScriptType::Item, i);
17859 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
17860 did_scripta=true;
17861 }
17862 }
17863 }
17864 else
17865 {
17866 item_error();
17867 }
17868 }
17869 else
17870 {
17871 did_scripta=false;
17872 }
17873
17874 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
17875 {
17876 if(DrunkUp() && canSideviewLadder())
17877 {
17878 setOnSideviewLadder(true);
17879 }
17880 else if(DrunkDown() && canSideviewLadder(true))
17881 {
17882 y+=1;
17883 setOnSideviewLadder(true);
17884 }
17885 }
17886
17887 int32_t wx=x;
17888 int32_t wy=y;
17889 if(conv_forcedir > -1) dir = conv_forcedir;
17890 else if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
17891 {
17892 if((xoff==0)||diagonalMovement)
17893 {
17894 if(DrunkUp()) dir=up;
17895 if(DrunkDown()) dir=down;
17896 }
17897
17898 if((yoff==0)||diagonalMovement)
17899 {
17900 if(DrunkLeft()) dir=left;
17901 if(DrunkRight()) dir=right;
17902 }
17903 }
17904
17905 switch(dir)
17906 {
17907 case up:
17908 wy-=16;
17909 break;
17910
17911 case down:
17912 wy+=16;
17913 break;
17914
17915 case left:
17916 wx-=16;
17917 break;
17918
17919 case right:
17920 wx+=16;
17921 break;
17922 }
17923
17924 do_lens();
17925
17926 bool no_jinx = true;
17927 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
17928 {
17929 bool paidmagic = false;
17930 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
17931 if(!liftonly && btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
17932 {
17933 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
17934 no_jinx = checkitem_jinx(attackid);
17935 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17936 {
17937 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
17938 paymagiccost(attackid,true);
17939 misc_internal_hero_flags |= LF_PAID_WAND_COST;
17940 }
17941 SetAttack();
17942 attack=wWand;
17943 attackclk=0;
17944 }
17945 else
17946 {
17947 item_error();
17948 }
17949 }
17950 else if(!liftonly && (btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
17951 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
17952 {
17953 no_jinx = checkitem_jinx(dowpn);
17954 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
17955 {
17956 item_error();
17957 }
17958 else
17959 {
17960 paymagiccost(dowpn);
17961 paidmagic = true;
17962 SetAttack();
17963 attack=wHammer;
17964 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
17965 attackclk=0;
17966 }
17967 }
17968 else if(!liftonly && (btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
17969 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
17970 {
17971 //checkbunny handled where magic cost is paid
17972 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
17973 no_jinx = checkitem_jinx(attackid);
17974 if(no_jinx)
17975 {
17976 SetAttack();
17977 attack=wFire;
17978 attackclk=0;
17979 }
17980 }
17981 else if(!liftonly && (btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
17982 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
17983 {
17984 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
17985 no_jinx = checkitem_jinx(attackid);
17986 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
17987 {
17988 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
17989 paymagiccost(attackid,true);
17990 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
17991 }
17992 SetAttack();
17993 attack=wCByrna;
17994 attackclk=0;
17995 }
17996 else
17997 {
17998 item_error();
17999 }
18000 }
18001 else if(!liftonly && (btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
18002 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
18003 {
18004 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
18005 no_jinx = checkitem_jinx(attackid);
18006 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
18007 {
18008 paymagiccost(attackid);
18009 SetAttack();
18010 attack = wBugNet;
18011 attackclk = 0;
18012 sfx(itemsbuf[attackid].usesound);
18013 }
18014 else
18015 {
18016 item_error();
18017 }
18018 }
18019 else
18020 {
18021 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
18022 no_jinx = checkitem_jinx(itmid);
18023 if(no_jinx)
18024 {
18025 paidmagic = startwpn(itmid);
18026
18027 if(paidmagic)
18028 {
18029 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
18030 {
18031 ;
18032 }
18033 else
18034 {
18035 SetAttack();
18036 attackclk=0;
18037 attack=none;
18038
18039 if(btnwpn==itype_brang)
18040 {
18041 attack=wBrang;
18042 }
18043 }
18044 }
18045 else
18046 {
18047 // Weapon not started: directWpn should be reset to prev. value.
18048 directWpn = olddirectwpn;
18049 }
18050 }
18051 }
18052
18053 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
18054 {
18055 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
18056 {
18057 item_error();
18058 }
18059 else
18060 {
18061 // Only charge for magic if item's magic cost wasn't already charged
18062 // for the item's main use.
18063 if(!paidmagic && attack!=wWand)
18064 paymagiccost(dowpn);
18065 //clear the item script stack for a new script
18066 int i = dowpn;
18067 FFCore.reset_script_engine_data(ScriptType::Item, i);
18068 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
18069 did_scriptb=true;
18070 }
18071 }
18072
18073 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
18074 {
18075 return false;
18076 }
18077 if(!no_jinx)
18078 did_scriptb = false;
18079 }
18080 else
18081 {
18082 did_scriptb=false;
18083 }
18084
18085 if(attackclk || action==attacking || action==sideswimattacking)
18086 {
18087 if(conv_forcedir > -1) dir = conv_forcedir;
18088 else if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
18089 {
18090 if((xoff==0)||diagonalMovement)
18091 {
18092 if(DrunkUp()) dir=up;
18093 if(DrunkDown()) dir=down;
18094 }
18095
18096 if((yoff==0)||diagonalMovement)
18097 {
18098 if(DrunkLeft()) dir=left;
18099 if(DrunkRight()) dir=right;
18100 }
18101 }
18102
18103 bool attacked = doattack();
18104
18105 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
18106 if(conv_forcedir > -1) dir = conv_forcedir;
18107 else if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
18108 {
18109 if((xoff==0)||diagonalMovement)
18110 {
18111 if(DrunkUp()) dir=up;
18112
18113 if(DrunkDown()) dir=down;
18114 }
18115
18116 if((yoff==0)||diagonalMovement)
18117 {
18118 if(DrunkLeft()) dir=left;
18119
18120 if(DrunkRight()) dir=right;
18121 }
18122 }
18123
18124 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
18125 {
18126 return false;
18127 }
18128 else if(!attacked)
18129 {
18130 // Spin attack - change direction
18131 if(spins>1 && attack != wHammer)
18132 {
18133 spins--;
18134
18135 if(spins%5==0)
18136 {
18137 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
18138 sfx(itemsbuf[id].usesound,pan(x.getInt()));
18139 }
18140 attackclk=1;
18141
18142 switch(dir)
18143 {
18144 case up:
18145 dir=left;
18146 break;
18147
18148 case right:
18149 dir=up;
18150 break;
18151
18152 case down:
18153 dir=right;
18154 break;
18155
18156 case left:
18157 dir=down;
18158 break;
18159 }
18160
18161 return false;
18162 }
18163 else
18164 {
18165 spins=0;
18166 }
18167
18168 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
18169 else {action=none; FFCore.setHeroAction(none);}
18170 attackclk=0;
18171 charging=0;
18172 }
18173 }
18174 return true;
18175 }
18176 void HeroClass::movehero()
18177 {
18178 auto push=pushing;
18179 pushing=0;
18180
18181 if(!is_conveyor_stunned) //these do not apply to conveyor auto-walk
18182 {
18183 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
18184 return;
18185
18186 if(action==walking) //still walking
18187 {
18188 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
18189 {
18190 if(attackclk>0) SetAttack();
18191 else {action = none; FFCore.setHeroAction(none);}
18192 hero_count=-1;
18193 return;
18194 }
18195
18196 autostep=false;
18197 } // endif (action==walking)
18198
18199 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
18200 {
18201 action=none; FFCore.setHeroAction(none);
18202 }
18203 }
18204
18205 bool nohorz = (isdungeon() && (y<=26 || y>=134) && !get_qr(qr_FREEFORM) && !toogam);
18206 bool novert = (isdungeon() && (x<=26 || x>=214) && !get_qr(qr_FREEFORM) && !toogam);
18207
18208 zfix dx, dy;
18209 if(is_conveyor_stunned)
18210 {
18211 dx = convey_forcex;
18212 dy = convey_forcey;
18213 convey_forcex = 0;
18214 convey_forcey = 0;
18215 if(action != walking)
18216 {
18217 action = walking; FFCore.setHeroAction(walking);
18218 }
18219 }
18220 else if(diagonalMovement)
18221 {
18222 switch(holddir)
18223 {
18224 case up:
18225 if(!Up())
18226 {
18227 holddir=-1;
18228 }
18229
18230 break;
18231
18232 case down:
18233 if(!Down())
18234 {
18235 holddir=-1;
18236 }
18237
18238 break;
18239
18240 case left:
18241 if(!Left())
18242 {
18243 holddir=-1;
18244 }
18245
18246 break;
18247
18248 case right:
18249 if(!Right())
18250 {
18251 holddir=-1;
18252 }
18253
18254 break;
18255
18256 default:
18257 break;
18258 } //end switch
18259
18260 if(DrunkUp()&&(holddir==-1||holddir==up)&&!novert)
18261 {
18262 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
18263 {
18264 dir=up;
18265 }
18266 holddir=up;
18267
18268 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18269 {
18270 shiftdir=right;
18271 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18272 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18273 }
18274 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18275 {
18276 shiftdir=left;
18277 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18278 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18279 }
18280 else
18281 {
18282 shiftdir=-1;
18283 }
18284 }
18285 else if(DrunkDown()&&(holddir==-1||holddir==down)&&!novert)
18286 {
18287 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
18288 {
18289 dir=down;
18290 }
18291 holddir=down;
18292
18293 if(DrunkRight()&&shiftdir!=left&&!nohorz)
18294 {
18295 shiftdir=right;
18296 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
18297 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
18298 }
18299 else if(DrunkLeft()&&shiftdir!=right&&!nohorz)
18300 {
18301 shiftdir=left;
18302 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
18303 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
18304 }
18305 else
18306 {
18307 shiftdir=-1;
18308 }
18309 }
18310 else if(DrunkLeft()&&(holddir==-1||holddir==left)&&!nohorz)
18311 {
18312 if(charging==0 && spins==0 && action != sideswimattacking)
18313 {
18314 dir=left;
18315 }
18316 sideswimdir = left;
18317 holddir=left;
18318
18319 if(DrunkUp()&&shiftdir!=down&&!novert)
18320 {
18321 shiftdir=up;
18322 }
18323 else if(DrunkDown()&&shiftdir!=up&&!novert)
18324 {
18325 shiftdir=down;
18326 }
18327 else
18328 {
18329 shiftdir=-1;
18330 }
18331 }
18332 else if(DrunkRight()&&(holddir==-1||holddir==right)&&!nohorz)
18333 {
18334 if(charging==0 && spins==0 && action != sideswimattacking)
18335 {
18336 dir=right;
18337 }
18338 sideswimdir = right;
18339 holddir=right;
18340
18341 if(DrunkUp()&&shiftdir!=down&&!novert)
18342 {
18343 shiftdir=up;
18344 }
18345 else if(DrunkDown()&&shiftdir!=up&&!novert)
18346 {
18347 shiftdir=down;
18348 }
18349 else
18350 {
18351 shiftdir=-1;
18352 }
18353 }
18354 else
18355 {
18356 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
18357 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
18358 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
18359 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
18360 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
18361
18362 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
18363 {
18364 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
18365 {
18366 //action=swimming;
18367 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
18368 {
18369 hopclk = 0xFF;
18370 }
18371 }
18372 }
18373 return;
18374 }
18375 get_move(holddir,dx,dy,dir);
18376 }
18377 else //4-way
18378 {
18379 shiftdir = -1;
18380 holddir = -1;
18381 if(!novert && DrunkUp())
18382 {
18383 holddir = dir = up;
18384 }
18385 else if(!novert && DrunkDown())
18386 {
18387 holddir = dir = down;
18388 }
18389 else if(!nohorz && DrunkLeft())
18390 {
18391 holddir = dir = left;
18392 }
18393 else if(!nohorz && DrunkRight())
18394 {
18395 holddir = dir = right;
18396 }
18397 get_move(holddir,dx,dy,dir);
18398 }
18399 if(conv_forcedir > -1)
18400 dir = conv_forcedir;
18401
18402 if(!new_engine_move(dx,dy))
18403 pushing = push+1;
18404 }
18405
18406 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
18407 {
18408 dx = 0; dy = 0;
18409 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
18410 return;
18411
18412 zfix base_movepix(zfix(steprate) / 100);
18413 zfix movepix(base_movepix);
18414 zfix up_step(zfix(game->get_sideswim_up()) / 100);
18415 zfix left_step(zfix(game->get_sideswim_side()) / 100);
18416 zfix right_step(zfix(game->get_sideswim_side()) / 100);
18417 zfix down_step(zfix(game->get_sideswim_down()) / 100);
18418 std::vector<zfix*> steps;
18419 steps.push_back(&movepix);
18420 steps.push_back(&up_step);
18421 steps.push_back(&left_step);
18422 steps.push_back(&right_step);
18423 steps.push_back(&down_step);
18424
18425 mod_steps(steps);
18426
18427 up_step = -up_step;
18428 left_step = -left_step;
18429
18430
18431 zfix step(movepix);
18432 zfix step_diag(movepix);
18433
18434
18435 if (diagonalMovement)
18436 {
18437 //zprint2("Player's X is %d, Y is %d\n", x, y);
18438 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
18439 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
18440 {
18441 step = STEP_DIAGONAL(step);
18442 up_step = STEP_DIAGONAL(up_step);
18443 left_step = STEP_DIAGONAL(left_step);
18444 right_step = STEP_DIAGONAL(right_step);
18445 down_step = STEP_DIAGONAL(down_step);
18446 }
18447 switch (movedir)
18448 {
18449 case up:
18450 switch (shiftdir)
18451 {
18452 case left:
18453 dx = IsSideSwim() ? left_step : -step;
18454 break;
18455 case right:
18456 dx = IsSideSwim() ? right_step : step;
18457 break;
18458 }
18459 if (IsSideSwim())
18460 {
18461 dy = up_step;
18462 }
18463 else dy = -step;
18464 break;
18465 case down:
18466 switch (shiftdir)
18467 {
18468 case left:
18469 dx = -step;
18470 if (IsSideSwim()) dx = left_step;
18471 break;
18472 case right:
18473 dx = step;
18474 if (IsSideSwim()) dx = right_step;
18475 break;
18476 }
18477 dy = IsSideSwim() ? down_step : step;
18478 break;
18479 case left:
18480 switch (shiftdir)
18481 {
18482 case up:
18483 if (IsSideSwim())
18484 {
18485 dy = up_step;
18486 }
18487 else dy = -step;
18488 break;
18489 case down:
18490 dy = step;
18491 if (IsSideSwim()) dy = down_step;
18492 break;
18493 }
18494 dx = IsSideSwim() ? left_step : -step;
18495 break;
18496 case right:
18497 switch (shiftdir)
18498 {
18499 case up:
18500 if (!IsSideSwim()) dy = -step;
18501 if (IsSideSwim())
18502 {
18503 dy = up_step;
18504 }
18505 break;
18506 case down:
18507 dy = step;
18508 if (IsSideSwim()) dy = down_step;
18509 break;
18510 }
18511 dx = IsSideSwim() ? right_step : step;
18512 break;
18513 };
18514 }
18515 else
18516 {
18517 switch (movedir)
18518 {
18519 case up:
18520 dy = IsSideSwim() ? up_step : -step;
18521 break;
18522 case down:
18523 dy = IsSideSwim() ? down_step : step;
18524 break;
18525 case left:
18526 dx = IsSideSwim() ? left_step : -step;
18527 break;
18528 case right:
18529 dx = IsSideSwim() ? right_step : step;
18530 break;
18531 };
18532 }
18533
18534 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
18535 {
18536 facedir = movedir;
18537 }
18538 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18539 {
18540 facedir = shiftdir;
18541 }
18542 }
18543
18544 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
18545 {
18546 if(!dx && !dy) return true;
18547 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18548 {
18549 herostep();
18550
18551 //ack... don't walk if in midair! -DD
18552 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18553 {
18554 action=walking; FFCore.setHeroAction(walking);
18555 }
18556
18557 if(++hero_count > (16*hero_animation_speed))
18558 hero_count=0;
18559 }
18560 else if(!(frame & 1))
18561 {
18562 herostep();
18563 }
18564
18565 bool ret = true;
18566 if(charging==0 || attack!=wHammer)
18567 {
18568 ret = movexy(dx,dy,false,false,true);
18569 }
18570 return ret;
18571 }
18572
18573 3884109 void HeroClass::moveOld(int32_t d2)
18574 {
18575 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
18576 static bool totalskip = false;
18577
18578
3/6
✓ Branch 0 taken 3884109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3884109 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3884109 times.
3884109 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18579 return;
18580
18581 3884109 int32_t dx=0,dy=0;
18582 3884109 int32_t xstep=lsteps[x.getInt()&7];
18583 3884109 int32_t ystep=lsteps[y.getInt()&7];
18584 3884109 int32_t z3skip=0;
18585 3884109 int32_t z3diagskip=0;
18586
3/6
✓ Branch 0 taken 93776 times.
✓ Branch 1 taken 3790333 times.
✓ Branch 2 taken 93776 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7674442 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
18587
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 3640980 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
3790333 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
18588
2/2
✓ Branch 0 taken 3883523 times.
✓ Branch 1 taken 586 times.
3884109 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18589 3884109 bool is_swimming = (action == swimming);
18590
18591 //slow walk combo, or charging, moves at 2/3 speed
18592 if(
18593
4/4
✓ Branch 0 taken 3835560 times.
✓ Branch 1 taken 48549 times.
✓ Branch 2 taken 94139 times.
✓ Branch 3 taken 3741421 times.
3932658 (!is_swimming && (slowcharging ^ slowcombo))||
18594
2/2
✓ Branch 0 taken 48549 times.
✓ Branch 1 taken 3741421 times.
3789970 (is_swimming && (zinit.hero_swim_speed>60))
18595 )
18596 {
18597 142688 totalskip = false;
18598
18599
2/2
✓ Branch 0 taken 12179 times.
✓ Branch 1 taken 130509 times.
142688 if(diagonalMovement)
18600 {
18601 12179 skipstep=(skipstep+1)%6;
18602
18603
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 6035 times.
12179 if(skipstep%2==0) z3skip=1;
18604 6144 else z3skip=0;
18605
18606
2/2
✓ Branch 0 taken 8177 times.
✓ Branch 1 taken 4002 times.
12179 if(skipstep%3==0) z3diagskip=1;
18607 8177 else z3diagskip=0;
18608 12179 }
18609 else
18610 {
18611
2/2
✓ Branch 0 taken 90047 times.
✓ Branch 1 taken 40462 times.
130509 if(d2<left)
18612 {
18613
2/2
✓ Branch 0 taken 54375 times.
✓ Branch 1 taken 35672 times.
90047 if(ystep>1)
18614 {
18615 35672 skipstep^=1;
18616 35672 ystep=skipstep;
18617 35672 }
18618 90047 }
18619 else
18620 {
18621
2/2
✓ Branch 0 taken 24595 times.
✓ Branch 1 taken 15867 times.
40462 if(xstep>1)
18622 {
18623 15867 skipstep^=1;
18624 15867 xstep=skipstep;
18625 15867 }
18626 }
18627 }
18628 142688 }
18629 // else if(is_swimming || (slowcharging && slowcombo))
18630 else if(
18631
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3741421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3741532 (is_swimming && (zinit.hero_swim_speed<60))||
18632
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 3741310 times.
3741421 (slowcharging && slowcombo)
18633 )
18634 {
18635 //swimming, or charging on a slow combo, moves at 1/2 speed
18636 111 totalskip = !totalskip;
18637
18638
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
18639 {
18640 skipstep=0;
18641 }
18642 111 }
18643 else
18644 {
18645 3741310 totalskip = false;
18646
18647
2/2
✓ Branch 0 taken 3291827 times.
✓ Branch 1 taken 449483 times.
3741310 if(diagonalMovement)
18648 {
18649 449483 skipstep=0;
18650 449483 }
18651 }
18652
18653
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 3884053 times.
3884109 if(!totalskip)
18654 {
18655
2/2
✓ Branch 0 taken 461662 times.
✓ Branch 1 taken 3422391 times.
3884053 if(diagonalMovement)
18656 {
18657
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 73264 times.
✓ Branch 2 taken 52416 times.
✓ Branch 3 taken 182278 times.
✓ Branch 4 taken 153704 times.
461662 switch(d2)
18658 {
18659 case up:
18660
2/2
✓ Branch 0 taken 6844 times.
✓ Branch 1 taken 66420 times.
73264 if(shiftdir==left)
18661 {
18662
2/2
✓ Branch 0 taken 4943 times.
✓ Branch 1 taken 1901 times.
6844 if(walkable)
18663 {
18664 4943 dy-=1-z3diagskip;
18665 4943 dx-=1-z3diagskip;
18666 4943 z3step=2;
18667 4943 }
18668 else
18669 {
18670 1901 dx-=1-z3diagskip;
18671 1901 z3step=2;
18672 }
18673 6844 }
18674
2/2
✓ Branch 0 taken 9161 times.
✓ Branch 1 taken 57259 times.
66420 else if(shiftdir==right)
18675 {
18676
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 2446 times.
9161 if(walkable)
18677 {
18678 6715 dy-=1-z3diagskip;
18679 6715 dx+=1-z3diagskip;
18680 6715 z3step=2;
18681 6715 }
18682 else
18683 {
18684 2446 dx+=1-z3diagskip;
18685 2446 z3step=2;
18686 }
18687 9161 }
18688 else
18689 {
18690
2/2
✓ Branch 0 taken 18772 times.
✓ Branch 1 taken 38487 times.
57259 if(walkable)
18691 {
18692 38487 dy-=z3step-z3skip;
18693 38487 z3step=(z3step%2)+1;
18694 38487 }
18695 }
18696
18697 73264 break;
18698
18699 case down:
18700
2/2
✓ Branch 0 taken 6599 times.
✓ Branch 1 taken 45817 times.
52416 if(shiftdir==left)
18701 {
18702
2/2
✓ Branch 0 taken 4688 times.
✓ Branch 1 taken 1911 times.
6599 if(walkable)
18703 {
18704 4688 dy+=1-z3diagskip;
18705 4688 dx-=1-z3diagskip;
18706 4688 z3step=2;
18707 4688 }
18708 else
18709 {
18710 1911 dx-=1-z3diagskip;
18711 1911 z3step=2;
18712 }
18713 6599 }
18714
2/2
✓ Branch 0 taken 7444 times.
✓ Branch 1 taken 38373 times.
45817 else if(shiftdir==right)
18715 {
18716
2/2
✓ Branch 0 taken 5479 times.
✓ Branch 1 taken 1965 times.
7444 if(walkable)
18717 {
18718 5479 dy+=1-z3diagskip;
18719 5479 dx+=1-z3diagskip;
18720 5479 z3step=2;
18721 5479 }
18722 else
18723 {
18724 1965 dx+=1-z3diagskip;
18725 1965 z3step=2;
18726 }
18727 7444 }
18728 else
18729 {
18730
2/2
✓ Branch 0 taken 10461 times.
✓ Branch 1 taken 27912 times.
38373 if(walkable)
18731 {
18732 27912 dy+=z3step-z3skip;
18733 27912 z3step=(z3step%2)+1;
18734 27912 }
18735 }
18736
18737 52416 break;
18738
18739 case right:
18740
2/2
✓ Branch 0 taken 171358 times.
✓ Branch 1 taken 10920 times.
182278 if(shiftdir==up)
18741 {
18742
2/2
✓ Branch 0 taken 9559 times.
✓ Branch 1 taken 1361 times.
10920 if(walkable)
18743 {
18744 9559 dy-=1-z3diagskip;
18745 9559 dx+=1-z3diagskip;
18746 9559 z3step=2;
18747 9559 }
18748 else
18749 {
18750 1361 dy-=1-z3diagskip;
18751 1361 z3step=2;
18752 }
18753 10920 }
18754
2/2
✓ Branch 0 taken 9195 times.
✓ Branch 1 taken 162163 times.
171358 else if(shiftdir==down)
18755 {
18756
2/2
✓ Branch 0 taken 7863 times.
✓ Branch 1 taken 1332 times.
9195 if(walkable)
18757 {
18758 7863 dy+=1-z3diagskip;
18759 7863 dx+=1-z3diagskip;
18760 7863 z3step=2;
18761 7863 }
18762 else
18763 {
18764 1332 dy+=1-z3diagskip;
18765 1332 z3step=2;
18766 }
18767 9195 }
18768 else
18769 {
18770
2/2
✓ Branch 0 taken 16011 times.
✓ Branch 1 taken 146152 times.
162163 if(walkable)
18771 {
18772 146152 dx+=z3step-z3skip;
18773 146152 z3step=(z3step%2)+1;
18774 146152 }
18775 }
18776
18777 182278 break;
18778
18779 case left:
18780
2/2
✓ Branch 0 taken 144507 times.
✓ Branch 1 taken 9197 times.
153704 if(shiftdir==up)
18781 {
18782
2/2
✓ Branch 0 taken 8049 times.
✓ Branch 1 taken 1148 times.
9197 if(walkable)
18783 {
18784 8049 dy-=1-z3diagskip;
18785 8049 dx-=1-z3diagskip;
18786 8049 z3step=2;
18787 8049 }
18788 else
18789 {
18790 1148 dy-=1-z3diagskip;
18791 1148 z3step=2;
18792 }
18793 9197 }
18794
2/2
✓ Branch 0 taken 7228 times.
✓ Branch 1 taken 137279 times.
144507 else if(shiftdir==down)
18795 {
18796
2/2
✓ Branch 0 taken 6410 times.
✓ Branch 1 taken 818 times.
7228 if(walkable)
18797 {
18798 6410 dy+=1-z3diagskip;
18799 6410 dx-=1-z3diagskip;
18800 6410 z3step=2;
18801 6410 }
18802 else
18803 {
18804 818 dy+=1-z3diagskip;
18805 818 z3step=2;
18806 }
18807 7228 }
18808 else
18809 {
18810
2/2
✓ Branch 0 taken 14976 times.
✓ Branch 1 taken 122303 times.
137279 if(walkable)
18811 {
18812 122303 dx-=z3step-z3skip;
18813 122303 z3step=(z3step%2)+1;
18814 122303 }
18815 }
18816
18817 153704 break;
18818 }
18819 461662 }
18820 else
18821 {
18822
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 807545 times.
✓ Branch 2 taken 659092 times.
✓ Branch 3 taken 945249 times.
✓ Branch 4 taken 1010505 times.
3422391 switch(d2)
18823 {
18824 case up:
18825
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 807237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
807545 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
18826
18827 807545 break;
18828
18829 case down:
18830
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 659038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
659092 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
18831
18832 659092 break;
18833
18834 case left:
18835 945249 dx-=xstep;
18836 945249 break;
18837
18838 case right:
18839 1010505 dx+=xstep;
18840 1010505 break;
18841 }
18842 }
18843 3884053 }
18844
18845
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3883523 times.
✓ Branch 2 taken 3883244 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 3883048 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 3883048 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3883048 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3884109 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
18846 {
18847 3883048 dir=d2;
18848 3883048 }
18849
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
18850 {
18851 dir = shiftdir;
18852 }
18853
18854
3/4
✓ Branch 0 taken 3835560 times.
✓ Branch 1 taken 48549 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3835560 times.
3884109 if(action != swimming && !IsSideSwim())
18855 {
18856 3835560 herostep();
18857
18858 //ack... don't walk if in midair! -DD
18859
12/14
✓ Branch 0 taken 3834974 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 3834695 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 3834535 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 3834535 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 3685182 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
3835560 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
18860 {
18861 3752780 action=walking; FFCore.setHeroAction(walking);
18862 3752780 }
18863
18864
2/2
✓ Branch 0 taken 3632982 times.
✓ Branch 1 taken 202578 times.
3835560 if(++hero_count > (16*hero_animation_speed))
18865 202578 hero_count=0;
18866 3835560 }
18867
2/2
✓ Branch 0 taken 24277 times.
✓ Branch 1 taken 24272 times.
48549 else if(!(frame & 1))
18868 {
18869 24272 herostep();
18870 24272 }
18871
18872
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3883523 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
3884109 if(charging==0 || attack!=wHammer)
18873 {
18874 3884109 sprite::move((zfix)dx,(zfix)dy);
18875 3884109 }
18876 3884109 }
18877 3973137 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
18878 {
18879
4/6
✓ Branch 0 taken 3972822 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 3972822 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3972822 times.
3973137 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
18880 315 return;
18881
18882
3/4
✓ Branch 0 taken 3884109 times.
✓ Branch 1 taken 88713 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3884109 times.
3972822 if(!get_qr(qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
18883 {
18884 3884109 moveOld(d2);
18885 3884109 return;
18886 }
18887
18888
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 85737 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
174450 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
18889
5/6
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 85174 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 498 times.
✓ Branch 4 taken 563 times.
✗ Branch 5 not taken.
85737 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
18890 //!DIMITODO: add QR for slow combos under hero
18891
4/4
✓ Branch 0 taken 85737 times.
✓ Branch 1 taken 2976 times.
✓ Branch 2 taken 2976 times.
✓ Branch 3 taken 5952 times.
94665 if(slowcombo) for (int32_t i = 0; i <= 1; ++i)
18892 {
18893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5952 times.
5952 if(tmpscr2[i].valid!=0)
18894 {
18895
1/2
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
5952 if (get_qr(qr_OLD_BRIDGE_COMBOS))
18896 {
18897
2/4
✓ Branch 0 taken 5952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5952 times.
✗ Branch 3 not taken.
5952 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18898 {
18899 slowcombo = false;
18900 break;
18901 }
18902 5952 }
18903 else
18904 {
18905 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i])))
18906 {
18907 slowcombo = false;
18908 break;
18909 }
18910 }
18911 5952 }
18912 8928 }
18913
1/2
✓ Branch 0 taken 88713 times.
✗ Branch 1 not taken.
88713 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
18914 88713 bool is_swimming = (action == swimming);
18915 88713 bool fastSwim = (zinit.hero_swim_speed>60);
18916 88713 zfix rate(steprate);
18917 88713 int32_t shieldid = getCurrentActiveShield();
18918
1/2
✓ Branch 0 taken 88713 times.
✗ Branch 1 not taken.
88713 if(shieldid > -1)
18919 {
18920 itemdata const& shield = itemsbuf[shieldid];
18921 if(shield.flags & ITEM_FLAG10) //Change Speed flag
18922 {
18923 zfix perc = shield.misc7;
18924 perc /= 100;
18925 if(perc < 0)
18926 perc = (perc*-1)+1;
18927 rate = (rate * perc) + shield.misc8;
18928 }
18929 }
18930
18931 88713 zfix dx, dy;
18932 88713 zfix movepix(rate / 100);
18933 88713 zfix step(movepix);
18934 88713 zfix step_diag(movepix);
18935 88713 zfix up_step(game->get_sideswim_up() / -100.0);
18936 88713 zfix left_step(game->get_sideswim_side() / -100.0);
18937 88713 zfix right_step(game->get_sideswim_side() / 100.0);
18938 88713 zfix down_step(game->get_sideswim_down() / 100.0);
18939 88713 bool checkladder = false;
18940
18941
2/2
✓ Branch 0 taken 88711 times.
✓ Branch 1 taken 2 times.
88713 if(hero_newstep > movepix) hero_newstep = movepix;
18942
2/2
✓ Branch 0 taken 88711 times.
✓ Branch 1 taken 2 times.
88713 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
18943 //2/3 speed
18944
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 88713 times.
✓ Branch 2 taken 85737 times.
✓ Branch 3 taken 85737 times.
✓ Branch 4 taken 88713 times.
✓ Branch 5 taken 85737 times.
88713 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
18945 {
18946 174450 step = ((step / 3.0) * 2);
18947 174450 step_diag = ((step_diag / 3.0) * 2);
18948 174450 up_step = ((up_step / 3.0) * 2);
18949 174450 left_step = ((left_step / 3.0) * 2);
18950 174450 right_step = ((right_step / 3.0) * 2);
18951 174450 down_step = ((down_step / 3.0) * 2);
18952 174450 }
18953 //1/2 speed
18954
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 85737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85737 times.
85737 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
18955 {
18956 step /= 2;
18957 step_diag /= 2;
18958 up_step /= 2;
18959 left_step /= 2;
18960 right_step /= 2;
18961 down_step /= 2;
18962 }
18963 //normal speed
18964 else
18965 {
18966 //no modification
18967 }
18968
18969
1/2
✓ Branch 0 taken 88713 times.
✗ Branch 1 not taken.
88713 if(diagonalMovement)
18970 {
18971 //zprint2("Player's X is %d, Y is %d\n", x, y);
18972
6/6
✓ Branch 0 taken 70355 times.
✓ Branch 1 taken 18358 times.
✓ Branch 2 taken 73680 times.
✓ Branch 3 taken 4263 times.
✓ Branch 4 taken 32014 times.
✓ Branch 5 taken 60024 times.
135585 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
18973
4/4
✓ Branch 0 taken 55274 times.
✓ Branch 1 taken 51011 times.
✓ Branch 2 taken 4253 times.
✓ Branch 3 taken 51021 times.
4263 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
18974 {
18975
2/4
✓ Branch 0 taken 18862 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18862 times.
138910 if(hero_newstep > 0 && hero_newstep_diag > 0)
18976 {
18977 18862 step = STEP_DIAGONAL(step);
18978 18862 step_diag = STEP_DIAGONAL(step_diag);
18979 18862 up_step = STEP_DIAGONAL(up_step);
18980 18862 left_step = STEP_DIAGONAL(left_step);
18981 18862 right_step = STEP_DIAGONAL(right_step);
18982 18862 down_step = STEP_DIAGONAL(down_step);
18983 18862 }
18984 18862 }
18985
2/2
✓ Branch 0 taken 63442 times.
✓ Branch 1 taken 6441 times.
69883 if(hero_newstep < step) step = hero_newstep; //handle collision
18986
2/2
✓ Branch 0 taken 67186 times.
✓ Branch 1 taken 2697 times.
69883 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
18987
5/5
✓ Branch 0 taken 18830 times.
✓ Branch 1 taken 18358 times.
✓ Branch 2 taken 17853 times.
✓ Branch 3 taken 25078 times.
✓ Branch 4 taken 27424 times.
69883 switch(d2)
18988 {
18989 case up:
18990
3/3
✓ Branch 0 taken 14523 times.
✓ Branch 1 taken 1993 times.
✓ Branch 2 taken 1842 times.
18358 switch(shiftdir)
18991 {
18992 case left:
18993 1993 dx = -step_diag;
18994
1/2
✓ Branch 0 taken 1993 times.
✗ Branch 1 not taken.
1993 if (IsSideSwim()) dx = left_step;
18995 1993 break;
18996 case right:
18997 1842 dx = step_diag;
18998
1/2
✓ Branch 0 taken 1842 times.
✗ Branch 1 not taken.
1842 if (IsSideSwim()) dx = right_step;
18999 1842 break;
19000 }
19001
2/2
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 15974 times.
18358 if(walkable)
19002 {
19003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15974 times.
15974 if (!IsSideSwim()) dy = -step;
19004
1/2
✓ Branch 0 taken 15974 times.
✗ Branch 1 not taken.
15974 if (IsSideSwim())
19005 {
19006 dy = up_step;
19007 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
19008 }
19009 15974 }
19010 18358 break;
19011 case down:
19012
3/3
✓ Branch 0 taken 13327 times.
✓ Branch 1 taken 2204 times.
✓ Branch 2 taken 2322 times.
17853 switch(shiftdir)
19013 {
19014 case left:
19015 2204 dx = -step_diag;
19016
1/2
✓ Branch 0 taken 2204 times.
✗ Branch 1 not taken.
2204 if (IsSideSwim()) dx = left_step;
19017 2204 break;
19018 case right:
19019 2322 dx = step_diag;
19020
1/2
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
2322 if (IsSideSwim()) dx = right_step;
19021 2322 break;
19022 }
19023
2/2
✓ Branch 0 taken 1687 times.
✓ Branch 1 taken 16166 times.
17853 if(walkable)
19024 {
19025 16166 dy = step;
19026
1/2
✓ Branch 0 taken 16166 times.
✗ Branch 1 not taken.
16166 if (IsSideSwim()) dy = down_step;
19027 16166 }
19028 17853 break;
19029 case left:
19030
3/3
✓ Branch 0 taken 19858 times.
✓ Branch 1 taken 2836 times.
✓ Branch 2 taken 2384 times.
25078 switch(shiftdir)
19031 {
19032 case up:
19033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2836 times.
2836 if (!IsSideSwim()) dy = -step_diag;
19034
1/2
✓ Branch 0 taken 2836 times.
✗ Branch 1 not taken.
2836 if (IsSideSwim())
19035 {
19036 dy = up_step;
19037 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
19038 }
19039 2836 break;
19040 case down:
19041 2384 dy = step_diag;
19042
1/2
✓ Branch 0 taken 2384 times.
✗ Branch 1 not taken.
2384 if (IsSideSwim()) dy = down_step;
19043 2384 break;
19044 }
19045
2/2
✓ Branch 0 taken 2458 times.
✓ Branch 1 taken 22620 times.
25078 if(walkable)
19046 {
19047 22620 dx = -step;
19048
1/2
✓ Branch 0 taken 22620 times.
✗ Branch 1 not taken.
22620 if (IsSideSwim()) dx = left_step;
19049 22620 }
19050 25078 break;
19051 case right:
19052
3/3
✓ Branch 0 taken 22143 times.
✓ Branch 1 taken 2794 times.
✓ Branch 2 taken 2487 times.
27424 switch(shiftdir)
19053 {
19054 case up:
19055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2794 times.
2794 if (!IsSideSwim()) dy = -step_diag;
19056
1/2
✓ Branch 0 taken 2794 times.
✗ Branch 1 not taken.
2794 if (IsSideSwim())
19057 {
19058 dy = up_step;
19059 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
19060 }
19061 2794 break;
19062 case down:
19063 2487 dy = step_diag;
19064
1/2
✓ Branch 0 taken 2487 times.
✗ Branch 1 not taken.
2487 if (IsSideSwim()) dy = down_step;
19065 2487 break;
19066 }
19067
2/2
✓ Branch 0 taken 2452 times.
✓ Branch 1 taken 24972 times.
27424 if(walkable)
19068 {
19069 24972 dx = step;
19070
1/2
✓ Branch 0 taken 24972 times.
✗ Branch 1 not taken.
24972 if (IsSideSwim()) dx = right_step;
19071 24972 }
19072 27424 break;
19073 };
19074 107543 }
19075 else
19076 {
19077 if(hero_newstep < step) step = hero_newstep; //handle collision
19078 switch(d2)
19079 {
19080 case up:
19081 dy -= step;
19082 if (IsSideSwim()) dy = up_step;
19083 break;
19084 case down:
19085 dy += step;
19086 if (IsSideSwim()) dy = down_step;
19087 break;
19088 case left:
19089 dx -= step;
19090 if (IsSideSwim()) dx = left_step;
19091 break;
19092 case right:
19093 dx += step;
19094 if (IsSideSwim()) dx = right_step;
19095 break;
19096 };
19097 }
19098 107543 hero_newstep = movepix;
19099 107543 hero_newstep_diag = movepix;
19100
19101
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 107543 times.
✓ Branch 2 taken 88713 times.
✓ Branch 3 taken 18830 times.
✓ Branch 4 taken 88713 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88713 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 88713 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
107543 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
19102 {
19103 88713 dir=d2;
19104 88713 }
19105
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 18830 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
18830 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19106 {
19107 dir = shiftdir;
19108 }
19109
2/2
✓ Branch 0 taken 107531 times.
✓ Branch 1 taken 12 times.
107543 if(forceRate > -1)
19110 {
19111 12 checkladder = false;
19112
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(dir)
19113 {
19114 case right:
19115 case r_up:
19116 case r_down:
19117 12 dx = zfix(forceRate) / 100;
19118 12 break;
19119 case left:
19120 case l_up:
19121 case l_down:
19122 dx = zfix(-forceRate) / 100;
19123 break;
19124 default:
19125 dx = 0;
19126 }
19127
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 switch(dir)
19128 {
19129 case down:
19130 case r_down:
19131 case l_down:
19132 dy = zfix(forceRate) / 100;
19133 break;
19134 case up:
19135 case r_up:
19136 case l_up:
19137 dy = zfix(-forceRate) / 100;
19138 break;
19139 default:
19140 12 dy = 0;
19141 12 }
19142 12 }
19143
4/4
✓ Branch 0 taken 32760 times.
✓ Branch 1 taken 74783 times.
✓ Branch 2 taken 26330 times.
✓ Branch 3 taken 6430 times.
107543 if(dx == 0 && dy == 0) return;
19144
5/8
✓ Branch 0 taken 82283 times.
✓ Branch 1 taken 18830 times.
✓ Branch 2 taken 82283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 82283 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 82283 times.
101113 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19145 {
19146 82283 herostep();
19147
19148 //ack... don't walk if in midair! -DD
19149
10/14
✓ Branch 0 taken 82283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 81745 times.
✓ Branch 5 taken 538 times.
✓ Branch 6 taken 81745 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 546 times.
✓ Branch 9 taken 81199 times.
✓ Branch 10 taken 48 times.
✓ Branch 11 taken 498 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 48 times.
82283 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
19150 {
19151 81697 action=walking; FFCore.setHeroAction(walking);
19152 81697 }
19153
19154
2/2
✓ Branch 0 taken 78070 times.
✓ Branch 1 taken 4213 times.
82283 if(++hero_count > (16*hero_animation_speed))
19155 4213 hero_count=0;
19156 82283 }
19157
1/2
✓ Branch 0 taken 18830 times.
✗ Branch 1 not taken.
18830 else if(!(frame & 1))
19158 {
19159 herostep();
19160 }
19161
19162
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 101113 times.
✓ Branch 2 taken 18830 times.
✓ Branch 3 taken 18830 times.
101113 if(charging==0 || attack!=wHammer)
19163 {
19164 119943 sprite::move(dx, dy);
19165 119943 WalkflagInfo info;
19166 119943 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
19167 119943 execute(info);
19168
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 82283 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 82283 times.
✗ Branch 7 not taken.
119943 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
19169 {
19170 if (game->get_sideswim_jump() != 0)
19171 {
19172 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
19173 sfx(WAV_ZN1SPLASH,(int32_t)x);
19174 hopclk = 0;
19175 if (charging || spins) action = attacking;
19176 else action = none;
19177 }
19178 else
19179 {
19180 sprite::move(zfix(0), zfix(-1*dy));
19181 }
19182 }
19183 82283 }
19184 3991967 }
19185
19186 17599136 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
19187 {
19188 17599136 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
19189 }
19190 17599136 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
19191 {
19192 17599136 WalkflagInfo ret;
19193
19194 17599136 wx = vbound(wx, -1, 256);
19195 17599136 wy = vbound(wy, -1, 176);
19196
19197
8/8
✓ Branch 0 taken 17525705 times.
✓ Branch 1 taken 73431 times.
✓ Branch 2 taken 17454794 times.
✓ Branch 3 taken 70911 times.
✓ Branch 4 taken 17454501 times.
✓ Branch 5 taken 293 times.
✓ Branch 6 taken 3119 times.
✓ Branch 7 taken 17451382 times.
17599136 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
19198 {
19199 147754 ret.setUnwalkable(false);
19200 147754 return ret;
19201 }
19202
19203
2/2
✓ Branch 0 taken 44026 times.
✓ Branch 1 taken 17407356 times.
17451382 if(toogam)
19204 {
19205 44026 ret.setUnwalkable(false);
19206 44026 return ret;
19207 }
19208
19209
4/4
✓ Branch 0 taken 388135 times.
✓ Branch 1 taken 17019221 times.
✓ Branch 2 taken 365572 times.
✓ Branch 3 taken 22563 times.
17407356 if(blockpath && wy<(bigHitbox?80:88))
19210 {
19211 22563 ret.setUnwalkable(true);
19212 22563 return ret;
19213 }
19214
19215
4/4
✓ Branch 0 taken 180398 times.
✓ Branch 1 taken 17204395 times.
✓ Branch 2 taken 136385 times.
✓ Branch 3 taken 44013 times.
17384793 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
19216 {
19217 44013 ret.setUnwalkable(true);
19218 44013 return ret;
19219 }
19220
19221
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 17340770 times.
17340780 if (collide_object(wx, wy,1, 1))
19222 {
19223 10 ret.setUnwalkable(true);
19224 10 return ret;
19225 }
19226
19227
15/22
✓ Branch 0 taken 9148089 times.
✓ Branch 1 taken 8192681 times.
✓ Branch 2 taken 8827212 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 8537320 times.
✓ Branch 5 taken 289892 times.
✓ Branch 6 taken 289892 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 289892 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 289892 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 147665 times.
✓ Branch 15 taken 142227 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 142227 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 142227 times.
✓ Branch 20 taken 23842 times.
✓ Branch 21 taken 17316928 times.
17507901 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
19228
2/2
✓ Branch 0 taken 19466 times.
✓ Branch 1 taken 122761 times.
289892 && !get_qr(qr_FREEFORM))
19229 {
19230 23842 ret.setUnwalkable(true);
19231 23842 return ret;
19232 }
19233
19234
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17316928 times.
✓ Branch 2 taken 17316928 times.
✗ Branch 3 not taken.
17316928 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
19235
19236
6/6
✓ Branch 0 taken 9124247 times.
✓ Branch 1 taken 8192681 times.
✓ Branch 2 taken 8803370 times.
✓ Branch 3 taken 320877 times.
✓ Branch 4 taken 2578134 times.
✓ Branch 5 taken 6225236 times.
17316928 if(isdungeon() && currscr<128 && !get_qr(qr_FREEFORM))
19237 {
19238
3/6
✓ Branch 0 taken 6225236 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225236 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6225236 times.
6225236 if((diagonalMovement||NO_GRIDLOCK))
19239 {
19240 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
19241
19242 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
19243 }
19244 6225236 }
19245 //All problems related to exiting water are probably here. -Z
19246
3/4
✓ Branch 0 taken 16968888 times.
✓ Branch 1 taken 348040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16968888 times.
17316928 if(action==swimming || IsSideSwim())
19247 {
19248
2/2
✓ Branch 0 taken 329591 times.
✓ Branch 1 taken 18449 times.
348040 if(!wf)
19249 {
19250 18449 bool isthissolid = false;
19251
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18449 times.
✓ Branch 4 taken 4525 times.
✓ Branch 5 taken 13924 times.
22974 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19252
4/6
✓ Branch 0 taken 13924 times.
✓ Branch 1 taken 4525 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4525 times.
18449 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
19253
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4525 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4525 times.
4525 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
19254
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4525 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4525 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4525 times.
18449 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
19255 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
19256
19257
19258
5/6
✓ Branch 0 taken 6944 times.
✓ Branch 1 taken 11505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6944 times.
✓ Branch 4 taken 9951 times.
✓ Branch 5 taken 28244 times.
29954 if(landswim>= (get_qr(qr_DROWN) && isSwimming() ? 1
19259
2/2
✓ Branch 0 taken 2107 times.
✓ Branch 1 taken 9398 times.
11505 : (!diagonalMovement) ? 1 : (get_qr(qr_NO_HOPPING)?1:22)))
19260 {
19261 //Check for out of bounds for swimming
19262 9951 bool changehop = true;
19263
19264
5/6
✓ Branch 0 taken 905 times.
✓ Branch 1 taken 9046 times.
✓ Branch 2 taken 905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9016 times.
✓ Branch 5 taken 8207 times.
9951 if((diagonalMovement||NO_GRIDLOCK))
19265 {
19266
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
18062 if(wx<0||wy<0)
19267 changehop = false;
19268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 else if(wx>248)
19269 changehop = false;
19270
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 else if(wx>240&&cnt==2)
19271 changehop = false;
19272
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
30 else if(wy>168)
19273 3 changehop = false;
19274 30 }
19275
3/4
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 7302 times.
✓ Branch 2 taken 8237 times.
✗ Branch 3 not taken.
8237 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
19276 //This may be where the hang-up for exiting water exists. -Z
19277 // hop out of the water
19278
2/2
✓ Branch 0 taken 7305 times.
✓ Branch 1 taken 932 times.
8237 if(changehop)
19279 932 ret.setHopClk(1);
19280 8237 }
19281 else
19282 {
19283
6/6
✓ Branch 0 taken 13375 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 15872 times.
✓ Branch 3 taken 12372 times.
✓ Branch 4 taken 8308 times.
✓ Branch 5 taken 7564 times.
28244 if((!(get_qr(qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
19284 {
19285 //int32_t vx=((int32_t)x+4)&0xFFF8;
19286 //int32_t vy=((int32_t)y+4)&0xFFF8;
19287
2/2
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 3936 times.
15872 if(d2==left)
19288 {
19289
4/4
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 1108 times.
✓ Branch 3 taken 98 times.
2316 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
19290
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1108 times.
1110 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
19291
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1108 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1108 times.
1108 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19292
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1108 times.
1108 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19293 {
19294 1108 ret.setHopDir(d2);
19295 1108 ret.setIlswim(true);
19296 1108 }
19297 98 else ret.setIlswim(false);
19298 1206 }
19299
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 1070 times.
3936 else if(d2==right)
19300 {
19301
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 1602 times.
✓ Branch 2 taken 1264 times.
✓ Branch 3 taken 1602 times.
4130 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
19302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1264 times.
1264 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
19303
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1264 times.
1264 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
19304
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1264 times.
1264 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
19305 {
19306 1264 ret.setHopDir(d2);
19307 1264 ret.setIlswim(true);
19308 1264 }
19309 1602 else ret.setIlswim(false);
19310 2866 }
19311
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 517 times.
1070 else if(d2==up)
19312 {
19313
4/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 95 times.
941 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
19314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424 times.
424 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
19315
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 422 times.
424 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
19316
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
422 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
19317 {
19318 422 ret.setHopDir(d2);
19319 422 ret.setIlswim(true);
19320 422 }
19321 95 else ret.setIlswim(false);
19322 517 }
19323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 553 times.
553 else if(d2==down)
19324 {
19325
4/4
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 270 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 270 times.
836 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
19326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
283 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
19327
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 283 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 283 times.
283 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
19328
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
283 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
19329 {
19330 283 ret.setHopDir(d2);
19331 283 ret.setIlswim(true);
19332 283 }
19333 270 else ret.setIlswim(false);
19334 553 }
19335 5142 }
19336
19337
2/4
✓ Branch 0 taken 17514 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17514 times.
17514 if(wx<0||wy<0);
19338
2/2
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 15268 times.
17514 else if(wx>248);
19339
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15268 else if(wx>240&&cnt==2);
19340
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 14773 times.
15268 else if(wy>168);
19341
3/4
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 8668 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6105 times.
14773 else if(get_qr(qr_DROWN) && !ilswim);
19342 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
19343
2/2
✓ Branch 0 taken 8650 times.
✓ Branch 1 taken 18 times.
8668 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
19344 {
19345 18 ret.setUnwalkable(false);
19346 18 return ret;
19347 }
19348 else
19349 {
19350 8650 ret.setUnwalkable(true);
19351 8650 return ret;
19352 }
19353 }
19354 17083 }
19355 else
19356 {
19357 329591 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19358 329591 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
19359
19360
8/8
✓ Branch 0 taken 304351 times.
✓ Branch 1 taken 25240 times.
✓ Branch 2 taken 273583 times.
✓ Branch 3 taken 30768 times.
✓ Branch 4 taken 25240 times.
✓ Branch 5 taken 30768 times.
✓ Branch 6 taken 18089 times.
✓ Branch 7 taken 7151 times.
329591 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19361 {
19362 291672 ret.setUnwalkable(false);
19363 291672 return ret;
19364 }
19365 }
19366 55002 }
19367
2/2
✓ Branch 0 taken 269378 times.
✓ Branch 1 taken 16699510 times.
16968888 else if(ladderx+laddery) // ladder is being used
19368 {
19369
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 263368 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 53 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
269378 int32_t lx = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
19370
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 263368 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 53 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
269378 int32_t ly = !(get_qr(qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
19371
19372
4/6
✓ Branch 0 taken 269229 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 269229 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 269229 times.
269378 if((diagonalMovement||NO_GRIDLOCK))
19373 {
19374
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(ladderdir==up)
19375 {
19376 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
19377 {
19378 bool temp = false;
19379
19380 if(!(abs(lx-(ladderx+8))<=8))
19381 temp = true;
19382
19383 if(cnt==2)
19384 if(!(abs((lx+8)-(ladderx+8))<=8))
19385 temp=true;
19386
19387 if(!temp)
19388 {
19389 ret.setUnwalkable(false);
19390 return ret;
19391 }
19392
19393 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
19394 {
19395 ret.setUnwalkable(true);
19396 return ret;
19397 }
19398 }
19399 }
19400 else
19401 {
19402
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 71 times.
149 if(abs(lx-(ladderx+8))<=8)
19403 {
19404
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 49 times.
71 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
19405 {
19406 22 ret.setUnwalkable(false);
19407 22 return ret;
19408 }
19409
19410
5/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
49 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
19411 {
19412 13 ret.setUnwalkable(true);
19413 13 return ret;
19414 }
19415
19416
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
36 if((abs(ly-laddery+8)<=8) && d2<=down)
19417 {
19418 ret.setUnwalkable(false);
19419 return ret;
19420 }
19421 36 }
19422 }
19423 114 } // diagonalMovement
19424 else
19425 {
19426
2/2
✓ Branch 0 taken 162695 times.
✓ Branch 1 taken 106534 times.
269229 if((d2&2)==ladderdir) // same direction
19427 {
19428
3/3
✓ Branch 0 taken 9688 times.
✓ Branch 1 taken 144319 times.
✓ Branch 2 taken 8688 times.
162695 switch(d2)
19429 {
19430 case up:
19431
2/2
✓ Branch 0 taken 6045 times.
✓ Branch 1 taken 2643 times.
8688 if(y.getInt()<=laddery)
19432 {
19433
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6045 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6045 times.
✓ Branch 4 taken 432 times.
✓ Branch 5 taken 5613 times.
11658 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
19434
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5613 times.
5613 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
19435 6045 return ret;
19436
19437 }
19438
19439 [[fallthrough]];
19440 case down:
19441
2/2
✓ Branch 0 taken 6627 times.
✓ Branch 1 taken 5704 times.
12331 if((wy&0xF0)==laddery)
19442 {
19443 6627 ret.setUnwalkable(false);
19444 6627 return ret;
19445 }
19446
19447 5704 break;
19448
19449 default:
19450
2/2
✓ Branch 0 taken 57797 times.
✓ Branch 1 taken 86522 times.
144319 if((wx&0xF0)==ladderx)
19451 {
19452 57797 ret.setUnwalkable(false);
19453 57797 return ret;
19454 }
19455 86522 }
19456
19457
2/2
✓ Branch 0 taken 5704 times.
✓ Branch 1 taken 86522 times.
92226 if(d2<=down)
19458 {
19459
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5704 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5704 times.
✓ Branch 4 taken 601 times.
✓ Branch 5 taken 5103 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5103 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5103 times.
5704 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
19460 5704 return ret;
19461 }
19462
19463
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 86522 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86522 times.
✓ Branch 4 taken 16586 times.
✓ Branch 5 taken 69936 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 69936 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 69936 times.
86522 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
19464 86522 return ret;
19465 }
19466
19467 // different dir
19468
3/8
✓ Branch 0 taken 106105 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
106534 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
19469 {
19470 106105 ret.setUnwalkable(true);
19471 106105 return ret;
19472 }
19473
19474
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
19475 {
19476 20 ret.setUnwalkable(false);
19477 20 return ret;
19478 }
19479 }
19480 523 }
19481
6/6
✓ Branch 0 taken 13881761 times.
✓ Branch 1 taken 2817749 times.
✓ Branch 2 taken 13584133 times.
✓ Branch 3 taken 297628 times.
✓ Branch 4 taken 1472510 times.
✓ Branch 5 taken 12111623 times.
16699510 else if(wf || isSideViewHero() || get_qr(qr_DROWN))
19482 {
19483 // see if it's a good spot for the ladder or for swimming
19484
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4587887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4587887 times.
4587887 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
19485
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4587887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4587887 times.
4587887 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
19486
19487
2/2
✓ Branch 0 taken 2298930 times.
✓ Branch 1 taken 2288957 times.
4587887 if(get_qr(qr_DROWN))
19488 {
19489 // Drowning changes the following attributes:
19490 // * Dangerous water is also walkable, so ignore the previous
19491 // definitions of unwalkablex and unwalkablex8.
19492 // * Instead, prevent the ladder from being used in the
19493 // one frame where Hero has landed on water before drowning.
19494 2288957 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
19495 2288957 }
19496
19497 // check if he can swim
19498
5/6
✓ Branch 0 taken 1399469 times.
✓ Branch 1 taken 3188418 times.
✓ Branch 2 taken 1399253 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1399253 times.
4587887 if(current_item(itype_flippers) && z==0 && fakez==0)
19499 {
19500 1399253 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
19501 1399253 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
19502
2/6
✓ Branch 0 taken 1399253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1399253 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1399253 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
19503 {
19504 //ladder ignores water combos that are now walkable thanks to flippers -DD
19505
2/2
✓ Branch 0 taken 6215 times.
✓ Branch 1 taken 1393038 times.
1399253 unwalkablex = unwalkablex && (!wtrx);
19506
2/2
✓ Branch 0 taken 624983 times.
✓ Branch 1 taken 774270 times.
1399253 unwalkablex8 = unwalkablex8 && (!wtrx8);
19507
19508
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1399243 times.
1399253 if(landswim >= 22)
19509 {
19510 10 ret.setHopClk(2);
19511 10 ret.setUnwalkable(false);
19512 10 return ret;
19513 }
19514
8/8
✓ Branch 0 taken 1221591 times.
✓ Branch 1 taken 177652 times.
✓ Branch 2 taken 7777 times.
✓ Branch 3 taken 1213814 times.
✓ Branch 4 taken 177652 times.
✓ Branch 5 taken 1213814 times.
✓ Branch 6 taken 1206 times.
✓ Branch 7 taken 176446 times.
1399243 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
19515 {
19516
4/6
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 2997 times.
✓ Branch 2 taken 5986 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5986 times.
8983 if(!(diagonalMovement||NO_GRIDLOCK))
19517 {
19518 5986 ret.setHopClk(2);
19519
19520
2/4
✓ Branch 0 taken 5986 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5986 times.
5986 if(charging || spins>5)
19521 {
19522 //if Hero is charging, he might be facing the wrong direction (we want him to
19523 //hop into the water, not in the facing direction)
19524 ret.setDir(d2);
19525 //moreover Hero can't charge in the water -DD
19526 ret.setChargeAttack();
19527 }
19528
19529 5986 ret.setUnwalkable(false);
19530 5986 return ret;
19531 }
19532
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 2711 times.
2997 else if(dir==d2)
19533 {
19534 2711 ret.setIlswim(true);
19535 2711 ladderx = 0;
19536 2711 laddery = 0;
19537 2711 }
19538 2997 }
19539 1393257 }
19540 1393257 }
19541
19542 // check if he can use the ladder
19543 // "Allow Ladder Anywhere" is toggled by fLADDER
19544
2/2
✓ Branch 0 taken 3239872 times.
✓ Branch 1 taken 1342019 times.
4581891 if(can_deploy_ladder())
19545 // laddersetup
19546 {
19547 // Check if there's water to use the ladder over
19548 1342019 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
19549 1342019 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
19550 1342019 int32_t ldrid = current_item_id(itype_ladder);
19551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1342019 times.
1342019 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
19552
19553
4/4
✓ Branch 0 taken 1333345 times.
✓ Branch 1 taken 8674 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1333325 times.
1342019 if(wtrx || wtrx8)
19554 {
19555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8694 times.
8694 if(isSideViewHero())
19556 {
19557 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19558 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
19559 }
19560 // * walk on half-water using the ladder instead of using flippers.
19561 // * otherwise, walk on ladder(+hookshot) combos.
19562
3/8
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 8220 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8694 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
19563 {
19564
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 387 times.
474 if(!get_qr(qr_OLD_210_WATER))
19565 {
19566 //if Hero could swim on a tile instead of using the ladder,
19567 //refuse to use the ladder to step over that tile. -DD
19568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
19569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
19570 387 }
19571 474 }
19572 8694 }
19573 else
19574 {
19575 // No water; check other things
19576
19577 //Check pits
19578
2/2
✓ Branch 0 taken 1332298 times.
✓ Branch 1 taken 1027 times.
1333325 if(ladderpits)
19579 {
19580 1027 int32_t pit_cmb = getpitfall(wx,wy);
19581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19582 1027 pit_cmb = getpitfall(x+8,wy);
19583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
19584 1027 }
19585
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1332298 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1333325 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
19586 {
19587 1333325 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
19588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1333325 times.
1333325 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19589 1333325 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
19590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1333325 times.
1333325 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
19591 1333325 }
19592 }
19593
19594
2/2
✓ Branch 0 taken 2684038 times.
✓ Branch 1 taken 1342019 times.
4026057 for (int32_t i = 0; i <= 1; ++i)
19595 {
19596
2/2
✓ Branch 0 taken 2290260 times.
✓ Branch 1 taken 393778 times.
2684038 if(tmpscr2[i].valid!=0)
19597 {
19598
2/2
✓ Branch 0 taken 328540 times.
✓ Branch 1 taken 65238 times.
393778 if (get_qr(qr_OLD_BRIDGE_COMBOS))
19599 {
19600
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328540 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 328540 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
328540 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19602 328540 }
19603 else
19604 {
19605
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 64979 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
65238 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
19606
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 65001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
65238 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
19607 }
19608 393778 }
19609 2684038 }
19610
2/2
✓ Branch 0 taken 1161587 times.
✓ Branch 1 taken 180432 times.
1342019 bool walkwater = (get_qr(qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
19611
19612
4/6
✓ Branch 0 taken 1301549 times.
✓ Branch 1 taken 40470 times.
✓ Branch 2 taken 1301549 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1301549 times.
1342019 if((diagonalMovement||NO_GRIDLOCK))
19613 {
19614
2/2
✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 28745 times.
40470 if(d2==dir)
19615 {
19616 28745 int32_t c = walkwater ? 0:8;
19617 28745 int32_t b = walkwater ? 8:0;
19618
19619
2/2
✓ Branch 0 taken 21217 times.
✓ Branch 1 taken 7528 times.
28745 if(d2>=left)
19620 {
19621 // If the difference between wy and y is small enough
19622
4/4
✓ Branch 0 taken 6210 times.
✓ Branch 1 taken 15007 times.
✓ Branch 2 taken 21214 times.
✓ Branch 3 taken 3 times.
21217 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
19623 {
19624 // Don't activate the ladder if it would be entirely
19625 // over water and Hero has the flippers. This isn't
19626 // a good way to do this, but it's too risky
19627 // to make big changes to this stuff.
19628 3 bool deployLadder=true;
19629 3 int32_t lx=wx&0xF0;
19630
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
3 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
19631 {
19632
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
19633 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
19634 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
19635 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
19636 deployLadder=false;
19637 2 }
19638
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(deployLadder)
19639 {
19640 3 ladderx = wx&0xF0;
19641 3 laddery = y;
19642 3 ladderdir = left;
19643 3 ladderstart = d2;
19644 3 ret.setUnwalkable(laddery!=y.getInt());
19645 3 return ret;
19646 }
19647 }
19648 21214 }
19649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7528 times.
7528 else if(d2<=down)
19650 {
19651 // If the difference between wx and x is small enough
19652
3/4
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7528 times.
7528 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
19653 {
19654 ladderx = x;
19655 laddery = wy&0xF0;
19656 ladderdir = up;
19657 ladderstart = d2;
19658 ret.setUnwalkable(ladderx!=x.getInt());
19659 return ret;
19660 }
19661
19662
2/2
✓ Branch 0 taken 2823 times.
✓ Branch 1 taken 4705 times.
7528 if(cnt==2)
19663 {
19664
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4705 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4705 times.
4705 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
19665 {
19666 ladderx = x;
19667 laddery = wy&0xF0;
19668 ladderdir = up;
19669 ladderstart = d2;
19670 ret.setUnwalkable(ladderx!=x.getInt());
19671 return ret;
19672 }
19673 4705 }
19674 7528 }
19675 28742 }
19676 40467 }
19677 else
19678 {
19679
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1301549 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1301549 times.
✓ Branch 4 taken 110262 times.
✓ Branch 5 taken 1191287 times.
1301549 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
19680
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1301549 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1301549 times.
✓ Branch 4 taken 1216046 times.
✓ Branch 5 taken 85503 times.
1301549 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
19681
19682
2/2
✓ Branch 0 taken 1200370 times.
✓ Branch 1 taken 101179 times.
1301585 if((d2>=left && wtrx)
19683 // Deploy the ladder vertically even if Hero is only half on water.
19684
8/8
✓ Branch 0 taken 13800 times.
✓ Branch 1 taken 1186570 times.
✓ Branch 2 taken 101179 times.
✓ Branch 3 taken 1186570 times.
✓ Branch 4 taken 884 times.
✓ Branch 5 taken 100295 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 101143 times.
1301549 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
19685 {
19686
4/4
✓ Branch 0 taken 13412 times.
✓ Branch 1 taken 388 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12883 times.
13800 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
19687 917 ladderdir = up;
19688 else
19689 12883 ladderdir = left;
19690
19691
2/2
✓ Branch 0 taken 12883 times.
✓ Branch 1 taken 917 times.
13800 if(ladderdir==up)
19692 {
19693 917 ladderx = x.getInt()&0xF8;
19694 917 laddery = wy&0xF0;
19695 917 }
19696 else
19697 {
19698 12883 ladderx = wx&0xF0;
19699 12883 laddery = y.getInt()&0xF8;
19700 }
19701
19702 13800 ret.setUnwalkable(false);
19703 13800 return ret;
19704 }
19705 }
19706 1328216 }
19707 4568088 }
19708
19709 16735236 ret.setUnwalkable(wf);
19710 16735236 return ret;
19711 17606438 }
19712
19713 // Only checks for moving blocks. Apparently this is a thing we need.
19714 1698866 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
19715 {
19716 1698866 HeroClass::WalkflagInfo ret;
19717
2/2
✓ Branch 0 taken 19341 times.
✓ Branch 1 taken 1679525 times.
1698866 if (!blockmoving) //Without this, weird swimming behaviors happen.
19718 {
19719 1679525 ret.setFlags(~1);
19720 1679525 ret.setHopDir(-1);
19721 1679525 }
19722
2/2
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 1696079 times.
1698866 if(toogam) return ret;
19723
2/2
✓ Branch 0 taken 1676738 times.
✓ Branch 1 taken 19341 times.
1696079 if (blockmoving)
19724 19341 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
19725
1/2
✓ Branch 0 taken 1696079 times.
✗ Branch 1 not taken.
1696079 if (collide_object(wx, wy,1, 1))
19726 ret.setUnwalkable(true);
19727 1696079 return ret;
19728 1698866 }
19729
19730 7109078 bool HeroClass::checksoliddamage()
19731 {
19732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7109078 times.
7109078 if(toogam) return false;
19733
19734
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7109078 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7109078 if (get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && get_qr(qr_NOSOLIDDAMAGECOMBOS)) return false; //no point checking if both of these rules are on
19735
19736
2/4
✓ Branch 0 taken 7109078 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7109078 times.
7109078 if(z!=0||fakez!=0) return false;
19737 7109078 int32_t bx = x.getInt();
19738 7109078 int32_t by = y.getInt();
19739 7109078 int32_t initk = 0;
19740
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1759616 times.
✓ Branch 2 taken 1377419 times.
✓ Branch 3 taken 1910396 times.
✓ Branch 4 taken 2061647 times.
7109078 switch(dir)
19741 {
19742 case up:
19743
19744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1759616 times.
1759616 by-=get_qr(qr_NEW_HERO_MOVEMENT2)?(bigHitbox ? 4 : -4):(bigHitbox ? 1 : -7);
19745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1759616 times.
1759616 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
19746
1/2
✓ Branch 0 taken 1759616 times.
✗ Branch 1 not taken.
1759616 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
19747
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1759516 times.
1759616 if(by<0)
19748 {
19749 100 return false;
19750 }
19751 1759516 break;
19752
19753 case down:
19754
19755 1377419 by+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
19756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377419 times.
1377419 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
19757
1/2
✓ Branch 0 taken 1377419 times.
✗ Branch 1 not taken.
1377419 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
19758
2/2
✓ Branch 0 taken 13264 times.
✓ Branch 1 taken 1364155 times.
1377419 if(by>175)
19759 {
19760 13264 return false;
19761 }
19762
19763 1364155 break;
19764
19765 case left:
19766 1910396 bx-=get_qr(qr_NEW_HERO_MOVEMENT2)?1:4;
19767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910396 times.
1910396 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
19768
1/2
✓ Branch 0 taken 1910396 times.
✗ Branch 1 not taken.
1910396 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
19769
3/4
✓ Branch 0 taken 1842184 times.
✓ Branch 1 taken 68212 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1842184 times.
1910396 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
19770 {
19771 1842184 by+=8;
19772 1842184 initk = 1;
19773 1842184 }
19774
2/2
✓ Branch 0 taken 10311 times.
✓ Branch 1 taken 1900085 times.
1910396 if(bx<0)
19775 {
19776 10311 return false;
19777 }
19778
19779 1900085 break;
19780
19781 case right:
19782 2061647 bx+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
19783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2061647 times.
2061647 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
19784
1/2
✓ Branch 0 taken 2061647 times.
✗ Branch 1 not taken.
2061647 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
19785
3/4
✓ Branch 0 taken 1984053 times.
✓ Branch 1 taken 77594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1984053 times.
2061647 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
19786 {
19787 1984053 by+=8;
19788 1984053 initk = 1;
19789 1984053 }
19790
2/2
✓ Branch 0 taken 15540 times.
✓ Branch 1 taken 2046107 times.
2061647 if(bx>255)
19791 {
19792 15540 return false;
19793 }
19794
19795 2046107 break;
19796 }
19797
1/2
✓ Branch 0 taken 7069863 times.
✗ Branch 1 not taken.
7069863 if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) initk++;
19798 7069863 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
19799 7069863 int32_t t = cmb.type;
19800
2/2
✓ Branch 0 taken 7069747 times.
✓ Branch 1 taken 116 times.
7069863 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19801 116 t = cNONE;
19802 7069863 int32_t initbx = bx;
19803 7069863 int32_t initby = by;
19804
19805 // Unlike push blocks, damage combos should be tested on layers 2 and under
19806
2/2
✓ Branch 0 taken 11505467 times.
✓ Branch 1 taken 7069849 times.
18575316 for(int32_t i=(get_qr(qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
19807 {
19808 11505467 bx = initbx;
19809 11505467 by = initby;
19810
2/2
✓ Branch 0 taken 4550841 times.
✓ Branch 1 taken 6954626 times.
11505467 if (!get_qr(qr_NOSOLIDDAMAGECOMBOS))
19811 {
19812
2/2
✓ Branch 0 taken 6954619 times.
✓ Branch 1 taken 17258063 times.
24212682 for (int32_t k = initk; k <= 2; k++)
19813 {
19814 17258063 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
19815 17258063 t = cmb.type;
19816
2/2
✓ Branch 0 taken 17257745 times.
✓ Branch 1 taken 318 times.
17258063 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
19817 318 t = cNONE;
19818 // Solid damage combos use pushing>0, hence the code is here.
19819
9/10
✓ Branch 0 taken 374646 times.
✓ Branch 1 taken 16883417 times.
✓ Branch 2 taken 72753 times.
✓ Branch 3 taken 301893 times.
✓ Branch 4 taken 69864 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 990 times.
✓ Branch 7 taken 68874 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 990 times.
17258063 if (!get_qr(qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
19820 {
19821
13/16
✓ Branch 0 taken 17239881 times.
✓ Branch 1 taken 14303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14303 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14303 times.
✓ Branch 6 taken 1190 times.
✓ Branch 7 taken 13113 times.
✓ Branch 8 taken 163 times.
✓ Branch 9 taken 1027 times.
✓ Branch 10 taken 66 times.
✓ Branch 11 taken 97 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 66 times.
✓ Branch 14 taken 17254118 times.
✓ Branch 15 taken 66 times.
17254184 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting)
19822 {
19823 // Bite Hero
19824
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 7 times.
66 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
19825 59 }
19826 17254177 }
19827
2/2
✓ Branch 0 taken 8741544 times.
✓ Branch 1 taken 8516512 times.
17258056 if (dir < left) bx += (k % 2) ? 7 : 8;
19828 8516512 else by += (k % 2) ? 7 : 8;
19829
1/2
✓ Branch 0 taken 17258056 times.
✗ Branch 1 not taken.
17258056 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) break;
19830 17258056 }
19831 6954619 }
19832
4/6
✓ Branch 0 taken 380025 times.
✓ Branch 1 taken 11125435 times.
✓ Branch 2 taken 380025 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 353100 times.
11858560 if(isSideViewHero() && !get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && // Check for sideview damage combos
19833
3/4
✓ Branch 0 taken 353100 times.
✓ Branch 1 taken 26925 times.
✓ Branch 2 taken 353100 times.
✗ Branch 3 not taken.
380025 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
19834 {
19835
2/2
✓ Branch 0 taken 33588 times.
✓ Branch 1 taken 319512 times.
353100 if (get_qr(qr_LESS_AWFUL_SIDESPIKES))
19836 {
19837
2/6
✓ Branch 0 taken 33588 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33588 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
33588 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
19838 {
19839
4/4
✓ Branch 0 taken 33584 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 33586 times.
✓ Branch 3 taken 2 times.
33588 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
19840 {
19841
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
19842 }
19843 33586 }
19844
1/2
✓ Branch 0 taken 33586 times.
✗ Branch 1 not taken.
33586 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
19845 33586 }
19846 else
19847 {
19848 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
19849
1/2
✓ Branch 0 taken 319512 times.
✗ Branch 1 not taken.
319512 if ( get_qr(qr_OLDSIDEVIEWSPIKES ) )
19850 {
19851
2/2
✓ Branch 0 taken 319507 times.
✓ Branch 1 taken 5 times.
639024 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
19852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
319512 x+8+(zc_max(tmpscr->csensitive-1,0)),
19853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
319512 y+17-(get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
19854
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 319512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319512 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
319512 y+17+zc_max((get_qr(qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
19855 5 return true;
19856 319507 }
19857 else //2.50.1 and later
19858 {
19859 if(checkdamagecombos(x+4, x+12, y+16, y+24))
19860 return true;
19861 }
19862 }
19863
19864 353093 }
19865 11505453 }
19866 7069849 return false;
19867 7109078 }
19868 7252157 void HeroClass::checkpushblock()
19869 {
19870
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 7237802 times.
7252157 if(toogam) return;
19871
19872
3/4
✓ Branch 0 taken 7233893 times.
✓ Branch 1 taken 3909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7233893 times.
7237802 if(z!=0||fakez!=0) return;
19873
19874 // Return early in some cases..
19875 7233893 bool earlyReturn=false;
19876
19877
5/6
✓ Branch 0 taken 6324736 times.
✓ Branch 1 taken 909157 times.
✓ Branch 2 taken 6324736 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6614870 times.
✓ Branch 5 taken 619023 times.
7233893 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
19878
2/2
✓ Branch 0 taken 2471210 times.
✓ Branch 1 taken 4143660 times.
6614870 if(x.getInt()&15) earlyReturn=true;
19879
19880 // if(y<16) return;
19881
4/4
✓ Branch 0 taken 252234 times.
✓ Branch 1 taken 6981659 times.
✓ Branch 2 taken 127419 times.
✓ Branch 3 taken 124815 times.
7233893 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
19882
19883 7109078 int32_t bx = x.getInt()&0xF0;
19884 7109078 int32_t by = (y.getInt()&0xF0);
19885
19886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1759616 times.
✓ Branch 2 taken 1377419 times.
✓ Branch 3 taken 1910396 times.
✓ Branch 4 taken 2061647 times.
7109078 switch(dir)
19887 {
19888 case up:
19889
2/2
✓ Branch 0 taken 59198 times.
✓ Branch 1 taken 1700418 times.
1759616 if(y<16)
19890 {
19891 59198 earlyReturn=true;
19892 59198 break;
19893 }
19894
19895
3/4
✓ Branch 0 taken 312814 times.
✓ Branch 1 taken 1387604 times.
✓ Branch 2 taken 312814 times.
✗ Branch 3 not taken.
1700418 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
19896
19897
2/2
✓ Branch 0 taken 973712 times.
✓ Branch 1 taken 726706 times.
1700418 if((int32_t)x&8) bx+=16;
19898
19899 1700418 break;
19900
19901 case down:
19902
2/2
✓ Branch 0 taken 98776 times.
✓ Branch 1 taken 1278643 times.
1377419 if(y>128)
19903 {
19904 98776 earlyReturn=true;
19905 98776 break;
19906 }
19907 else
19908 {
19909 1278643 by+=16;
19910
19911
2/2
✓ Branch 0 taken 812600 times.
✓ Branch 1 taken 466043 times.
1278643 if((int32_t)x&8) bx+=16;
19912 }
19913
19914 1278643 break;
19915
19916 case left:
19917
2/2
✓ Branch 0 taken 99027 times.
✓ Branch 1 taken 1811369 times.
1910396 if(x<32)
19918 {
19919 99027 earlyReturn=true;
19920 99027 break;
19921 }
19922 else
19923 {
19924 1811369 bx-=16;
19925
19926
2/2
✓ Branch 0 taken 1151471 times.
✓ Branch 1 taken 659898 times.
1811369 if(y.getInt()&8)
19927 {
19928 659898 by+=16;
19929 659898 }
19930 }
19931
19932 1811369 break;
19933
19934 case right:
19935
2/2
✓ Branch 0 taken 103413 times.
✓ Branch 1 taken 1958234 times.
2061647 if(x>208)
19936 {
19937 103413 earlyReturn=true;
19938 103413 break;
19939 }
19940 else
19941 {
19942 1958234 bx+=16;
19943
19944
2/2
✓ Branch 0 taken 1266977 times.
✓ Branch 1 taken 691257 times.
1958234 if(y.getInt()&8)
19945 {
19946 691257 by+=16;
19947 691257 }
19948 }
19949
19950 1958234 break;
19951 }
19952
19953
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7109064 times.
7109078 if (checksoliddamage()) return;
19954
19955
2/2
✓ Branch 0 taken 4232905 times.
✓ Branch 1 taken 2876159 times.
7109064 if(earlyReturn)
19956 4232905 return;
19957
19958 2876159 int itemid=current_item_id(itype_bracelet);
19959 2876159 size_t combopos = (by&0xF0)+(bx>>4);
19960
2/2
✓ Branch 0 taken 1325285 times.
✓ Branch 1 taken 1550874 times.
2876159 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
19961
2/2
✓ Branch 0 taken 1550874 times.
✓ Branch 1 taken 1325285 times.
2876159 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
19962
2/2
✓ Branch 0 taken 1143221 times.
✓ Branch 1 taken 5181484 times.
6324705 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
19963 {
19964
4/4
✓ Branch 0 taken 2320183 times.
✓ Branch 1 taken 2861301 times.
✓ Branch 2 taken 594140 times.
✓ Branch 3 taken 1726043 times.
5181484 if(get_qr(qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
19965
4/4
✓ Branch 0 taken 2300232 times.
✓ Branch 1 taken 1155209 times.
✓ Branch 2 taken 6562 times.
✓ Branch 3 taken 2293670 times.
3455441 if(lyr && !get_qr(qr_PUSHBLOCK_LAYER_1_2))
19966 2293670 continue;
19967 1161771 cpos_info& cpinfo = get_combo_posinfo(lyr, combopos);
19968 1161771 mapscr* m = FFCore.tempScreens[lyr];
19969
2/2
✓ Branch 0 taken 11656 times.
✓ Branch 1 taken 1150115 times.
1161771 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
19970 1161771 newcombo const& cmb = combobuf[cid];
19971 1161771 int f = MAPFLAG2(lyr-1,bx,by);
19972 1161771 int f2 = cmb.flag;
19973 1161771 int t = cmb.type;
19974
19975
6/6
✓ Branch 0 taken 1061617 times.
✓ Branch 1 taken 100154 times.
✓ Branch 2 taken 1058858 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 2027 times.
✓ Branch 5 taken 1056831 times.
2218602 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
19976
1/2
✓ Branch 0 taken 1056831 times.
✗ Branch 1 not taken.
1056831 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
19977 1161771 int heavy = 0;
19978
4/4
✓ Branch 0 taken 1153918 times.
✓ Branch 1 taken 7853 times.
✓ Branch 2 taken 7911 times.
✓ Branch 3 taken 1146007 times.
1161771 if(t==cPUSH_HW || t==cPUSH_HEAVY)
19979 15764 heavy = 1;
19980
4/4
✓ Branch 0 taken 1144701 times.
✓ Branch 1 taken 1306 times.
✓ Branch 2 taken 2027 times.
✓ Branch 3 taken 1142674 times.
1146007 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
19981 3333 heavy = 2;
19982
1/2
✓ Branch 0 taken 1142674 times.
✗ Branch 1 not taken.
1142674 else if(t == cPUSHBLOCK)
19983 heavy = cmb.attribytes[0];
19984
19985
6/6
✓ Branch 0 taken 99846 times.
✓ Branch 1 taken 1061925 times.
✓ Branch 2 taken 34028 times.
✓ Branch 3 taken 65818 times.
✓ Branch 4 taken 2753 times.
✓ Branch 5 taken 31275 times.
1161771 if(waitblock && (pushing<16 || hasMainGuy())) continue;
19986
19987
8/8
✓ Branch 0 taken 1082361 times.
✓ Branch 1 taken 10839 times.
✓ Branch 2 taken 9936 times.
✓ Branch 3 taken 903 times.
✓ Branch 4 taken 741 times.
✓ Branch 5 taken 9195 times.
✓ Branch 6 taken 1644 times.
✓ Branch 7 taken 1091556 times.
1113234 if(heavy && (itemid<0 || glove->power < heavy ||
19988
3/4
✓ Branch 0 taken 9189 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
10839 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
19989
19990 1091556 bool doit=false;
19991 1091556 bool changeflag=false;
19992 1091556 bool changecombo=false;
19993
19994 1091556 int blockdir = dir;
19995
1/2
✓ Branch 0 taken 1091556 times.
✗ Branch 1 not taken.
1091556 if(blockdir > 3) blockdir = Y_DIR(dir);
19996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1091556 times.
1091556 if(t == cPUSHBLOCK)
19997 {
19998 switch(blockdir)
19999 {
20000 case up:
20001 doit = cmb.usrflags & cflag1;
20002 break;
20003 case down:
20004 doit = cmb.usrflags & cflag2;
20005 break;
20006 case left:
20007 doit = cmb.usrflags & cflag3;
20008 break;
20009 case right:
20010 doit = cmb.usrflags & cflag4;
20011 break;
20012 }
20013 if(cmb.usrflags & cflag5) //Separate directions
20014 {
20015 if(int limit = cmb.attribytes[4+blockdir])
20016 {
20017 if(cpinfo.pushes[blockdir] >= limit)
20018 doit = false;
20019 }
20020 else if(cmb.usrflags & cflag9)
20021 doit = false;
20022 }
20023 else
20024 {
20025 if(int limit = cmb.attribytes[4])
20026 {
20027 if(cpinfo.sumpush() >= limit)
20028 doit = false;
20029 }
20030 else if(cmb.usrflags & cflag9)
20031 doit = false;
20032 }
20033 }
20034 else
20035 {
20036
8/8
✓ Branch 0 taken 1086266 times.
✓ Branch 1 taken 5290 times.
✓ Branch 2 taken 1086260 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 2996 times.
✓ Branch 5 taken 1088560 times.
✓ Branch 6 taken 680 times.
✓ Branch 7 taken 1082713 times.
2174949 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
20037
4/4
✓ Branch 0 taken 1086282 times.
✓ Branch 1 taken 2278 times.
✓ Branch 2 taken 1086279 times.
✓ Branch 3 taken 3 times.
1088560 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
20038
4/4
✓ Branch 0 taken 1086207 times.
✓ Branch 1 taken 2353 times.
✓ Branch 2 taken 1086078 times.
✓ Branch 3 taken 129 times.
1088560 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
20039
4/4
✓ Branch 0 taken 1086091 times.
✓ Branch 1 taken 2387 times.
✓ Branch 2 taken 1086090 times.
✓ Branch 3 taken 1 times.
1088478 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
20040
4/4
✓ Branch 0 taken 1086014 times.
✓ Branch 1 taken 2464 times.
✓ Branch 2 taken 1086013 times.
✓ Branch 3 taken 1 times.
1088478 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
20041
4/4
✓ Branch 0 taken 1085982 times.
✓ Branch 1 taken 2496 times.
✓ Branch 2 taken 1085980 times.
✓ Branch 3 taken 2 times.
1088478 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
20042
2/2
✓ Branch 0 taken 1083393 times.
✓ Branch 1 taken 93 times.
1083486 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
20043 {
20044 3769 changeflag=true;
20045 3769 doit=true;
20046 3769 }
20047
20048
7/8
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 1086472 times.
✓ Branch 6 taken 1086461 times.
✓ Branch 7 taken 1 times.
2172934 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
20049
3/4
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
1086472 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
20050
3/4
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
1086472 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
20051
3/4
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
1086472 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
20052
3/4
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
1086472 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
20053
3/4
✓ Branch 0 taken 1086462 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 1086462 times.
✗ Branch 3 not taken.
1086472 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
20054
1/2
✓ Branch 0 taken 1086452 times.
✗ Branch 1 not taken.
1086462 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
20055 {
20056 1 changecombo=true;
20057 1 doit=true;
20058 1 }
20059 }
20060
20061
2/2
✓ Branch 0 taken 749031 times.
✓ Branch 1 taken 337431 times.
1086462 if(get_qr(qr_SOLIDBLK))
20062 {
20063
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 86981 times.
✓ Branch 2 taken 77498 times.
✓ Branch 3 taken 77478 times.
✓ Branch 4 taken 95474 times.
337431 switch(blockdir)
20064 {
20065 case up:
20066
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 86981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86981 times.
✓ Branch 4 taken 54001 times.
✓ Branch 5 taken 32980 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 32980 times.
✓ Branch 8 taken 54005 times.
✓ Branch 9 taken 32976 times.
86981 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
20067
20068 86981 break;
20069
20070 case down:
20071
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 77498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77498 times.
✓ Branch 4 taken 46089 times.
✓ Branch 5 taken 31409 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 31409 times.
✓ Branch 8 taken 46093 times.
✓ Branch 9 taken 31405 times.
77498 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
20072
20073 77498 break;
20074
20075 case left:
20076
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 77478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77478 times.
✓ Branch 4 taken 33508 times.
✓ Branch 5 taken 43970 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 43970 times.
✓ Branch 8 taken 33514 times.
✓ Branch 9 taken 43964 times.
77478 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
20077
20078 77478 break;
20079
20080 case right:
20081
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 95474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 95474 times.
✓ Branch 4 taken 40004 times.
✓ Branch 5 taken 55470 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55470 times.
✓ Branch 8 taken 40014 times.
✓ Branch 9 taken 55460 times.
95474 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
20082
20083 95474 break;
20084 }
20085 337431 }
20086
20087
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 391005 times.
✓ Branch 2 taken 333326 times.
✓ Branch 3 taken 171660 times.
✓ Branch 4 taken 190471 times.
1086462 switch(blockdir)
20088 {
20089 case up:
20090
3/4
✓ Branch 0 taken 390642 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 390642 times.
391005 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
20091
20092 391005 break;
20093
20094 case down:
20095
3/4
✓ Branch 0 taken 332894 times.
✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332894 times.
333326 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
20096
20097 333326 break;
20098
20099 case left:
20100
3/4
✓ Branch 0 taken 171558 times.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 171558 times.
171660 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
20101
20102 171660 break;
20103
20104 case right:
20105
3/4
✓ Branch 0 taken 190371 times.
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 190371 times.
190471 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
20106
20107 190471 break;
20108 }
20109
20110
2/2
✓ Branch 0 taken 1084661 times.
✓ Branch 1 taken 1801 times.
1086462 if(doit)
20111 {
20112
2/2
✓ Branch 0 taken 1794 times.
✓ Branch 1 taken 7 times.
1801 if(limitedpush)
20113 7 ++usecounts[itemid];
20114
20115 // for(int32_t i=0; i<1; i++)
20116
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 1512 times.
1801 if(!blockmoving)
20117 {
20118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512 times.
1512 if(changeflag)
20119 {
20120 1512 m->sflag[combopos]=0;
20121 1512 }
20122
20123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512 times.
1512 if(mblock2.clk<=0)
20124 {
20125 1512 mblock2.blockLayer = lyr;
20126
20127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512 times.
1512 if(t == cPUSHBLOCK)
20128 {
20129 zfix blockstep = 0.5;
20130 if(cmb.attrishorts[0] > 0)
20131 blockstep = zslongToFix(cmb.attrishorts[0]*100);
20132 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
20133 mblock2.blockinfo = cpinfo;
20134 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
20135 cpinfo.clear();
20136 if(cmb.attribytes[1])
20137 sfx(cmb.attribytes[1],(int32_t)x);
20138 }
20139 else
20140 {
20141 1512 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
20142
20143
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1510 times.
1512 if(get_qr(qr_MORESOUNDS))
20144 2 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
20145 }
20146 1512 }
20147 1512 }
20148 1801 break;
20149 }
20150 1084661 }
20151 7247063 }
20152
20153 305 bool usekey()
20154 {
20155 305 int32_t itemid = current_item_id(itype_magickey);
20156
20157
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
305 if(itemid<0 ||
20158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20159 : itemsbuf[itemid].power!=dlevel))
20160 {
20161
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 208 times.
256 if(game->lvlkeys[dlevel]!=0)
20162 {
20163 48 game->lvlkeys[dlevel]--;
20164 //run script for level key item
20165 48 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
20166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
4080 for ( int32_t q = 0; q < MAXITEMS; ++q )
20167 {
20168
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 48 times.
4080 if ( itemsbuf[q].family == itype_lkey )
20169 {
20170 48 key_item = q; break;
20171 }
20172 4032 }
20173
20174
2/8
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
20175 {
20176 int i = key_item;
20177 FFCore.reset_script_engine_data(ScriptType::Item, i);
20178 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20179 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20180 }
20181 48 return true;
20182 }
20183 else
20184 {
20185
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 61 times.
208 if(game->get_keys()==0)
20186 {
20187 61 return false;
20188 }
20189 else
20190 {
20191 //run script for key item
20192 147 int32_t key_item = 0; //current_item_id(itype_key); //not possible
20193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1470 times.
1470 for ( int32_t q = 0; q < MAXITEMS; ++q )
20194 {
20195
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 147 times.
1470 if ( itemsbuf[q].family == itype_key )
20196 {
20197 147 key_item = q; break;
20198 }
20199 1323 }
20200 //zprint2("key_item is: %d\n",key_item);
20201 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
20202
2/8
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
147 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
20203 {
20204 int i = key_item;
20205 FFCore.reset_script_engine_data(ScriptType::Item, i);
20206 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20207 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20208 }
20209 147 game->change_keys(-1);
20210 }
20211 }
20212 147 }
20213
20214 196 return true;
20215 305 }
20216
20217 bool canUseKey(int32_t num)
20218 {
20219 int32_t itemid = current_item_id(itype_magickey);
20220
20221 if(itemid<0 ||
20222 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
20223 : itemsbuf[itemid].power!=dlevel))
20224 {
20225 return game->lvlkeys[dlevel] + game->get_keys() >= num;
20226 }
20227
20228 return true;
20229 }
20230
20231 bool usekey(int32_t num)
20232 {
20233 if(!canUseKey(num)) return false;
20234 for(auto q = 0; q < num; ++q)
20235 {
20236 if(!usekey()) return false; //should never return false here, but, just to be safe....
20237 }
20238 return true;
20239 }
20240
20241
20242 1443 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
20243 {
20244 1443 int32_t mc = (y&0xF0)+(x>>4);
20245
4/6
✓ Branch 0 taken 1443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1343 times.
✓ Branch 5 taken 100 times.
2886 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
20246
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1443 times.
✓ Branch 2 taken 1443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1443 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1443 times.
✗ Branch 7 not taken.
1443 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
20247
3/6
✓ Branch 0 taken 1443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1443 times.
✗ Branch 5 not taken.
1443 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
20248
5/8
✓ Branch 0 taken 1443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1418 times.
✓ Branch 5 taken 25 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1418 times.
1443 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
20249 1443 return ret;
20250 }
20251
20252 7227377 void HeroClass::oldchecklockblock()
20253 {
20254
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 7213022 times.
7227377 if(toogam) return;
20255
20256 7213022 int32_t bx = x.getInt()&0xF0;
20257 7213022 int32_t bx2 = int32_t(x+8)&0xF0;
20258 7213022 int32_t by = y.getInt()&0xF0;
20259
20260
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1770315 times.
✓ Branch 2 taken 1381487 times.
✓ Branch 3 taken 1952663 times.
✓ Branch 4 taken 2108557 times.
7213022 switch(dir)
20261 {
20262 case up:
20263
4/4
✓ Branch 0 taken 320945 times.
✓ Branch 1 taken 1449370 times.
✓ Branch 2 taken 6412 times.
✓ Branch 3 taken 314533 times.
1770315 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20264
20265 1770315 break;
20266
20267 case down:
20268 1381487 by+=16;
20269 1381487 break;
20270
20271 case left:
20272
2/2
✓ Branch 0 taken 854879 times.
✓ Branch 1 taken 1097784 times.
1952663 if((((int32_t)x)&0x0F)<8)
20273 1097784 bx-=16;
20274
20275
2/2
✓ Branch 0 taken 1244259 times.
✓ Branch 1 taken 708404 times.
1952663 if(y.getInt()&8)
20276 {
20277 708404 by+=16;
20278 708404 }
20279
20280 1952663 bx2=bx;
20281 1952663 break;
20282
20283 case right:
20284 2108557 bx+=16;
20285
20286
2/2
✓ Branch 0 taken 1367211 times.
✓ Branch 1 taken 741346 times.
2108557 if(y.getInt()&8)
20287 {
20288 741346 by+=16;
20289 741346 }
20290
20291 2108557 bx2=bx;
20292 2108557 break;
20293 }
20294
20295 7213022 bool found1=false;
20296 7213022 bool found2=false;
20297 7213022 int32_t foundlayer = -1;
20298 7213022 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20299 7213022 newcombo const& cmb = combobuf[cid1];
20300 7213022 newcombo const& cmb2 = combobuf[cid2];
20301 // Layer 0 is overridden by Locked Doors
20302
5/8
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 7212105 times.
✓ Branch 2 taken 917 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 917 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 917 times.
7213022 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
20303 {
20304 917 found1=true;
20305 917 foundlayer = 0;
20306 917 }
20307
5/8
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 7212068 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 37 times.
7212105 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
20308 {
20309 37 found2=true;
20310 37 foundlayer = 0;
20311 37 }
20312
20313
2/2
✓ Branch 0 taken 14426044 times.
✓ Branch 1 taken 7213022 times.
21639066 for (int32_t i = 0; i <= 1; ++i)
20314 {
20315
2/2
✓ Branch 0 taken 11714735 times.
✓ Branch 1 taken 2711309 times.
14426044 if(tmpscr2[i].valid!=0)
20316 {
20317
2/2
✓ Branch 0 taken 2603454 times.
✓ Branch 1 taken 107855 times.
2711309 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20318 {
20319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2603454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2603454 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2603454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2603454 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20321 2603454 }
20322 else
20323 {
20324
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
20325
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
20326 }
20327 2711309 }
20328 14426044 }
20329
20330
20331 // Layers
20332
4/4
✓ Branch 0 taken 7212105 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 7212068 times.
7213022 if(!(found1 || found2))
20333 {
20334 7212068 foundlayer = -1;
20335
2/2
✓ Branch 0 taken 7211983 times.
✓ Branch 1 taken 14424102 times.
21636085 for(int32_t i=0; i<2; i++)
20336 {
20337 14424102 cid1 = MAPCOMBO2(i, bx, by);
20338 14424102 cid2 = MAPCOMBO2(i, bx2, by);
20339 14424102 newcombo const& cmb = combobuf[cid1];
20340 14424102 newcombo const& cmb2 = combobuf[cid2];
20341
2/2
✓ Branch 0 taken 7212034 times.
✓ Branch 1 taken 7212068 times.
14424102 if (i == 0)
20342 {
20343
2/2
✓ Branch 0 taken 6235714 times.
✓ Branch 1 taken 976354 times.
7212068 if(tmpscr2[1].valid!=0)
20344 {
20345
2/2
✓ Branch 0 taken 931800 times.
✓ Branch 1 taken 44554 times.
976354 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20346 {
20347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931800 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
20348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931800 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
20349 931800 }
20350 else
20351 {
20352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20353
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20354 }
20355 976354 }
20356 7212068 }
20357
4/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 14424020 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 82 times.
14424102 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20358 {
20359 82 found1=true;
20360 82 foundlayer = i+1;
20361 //zprint("Found layer: %d \n", i);
20362 82 break;
20363 }
20364
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14424017 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
14424020 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
20365 {
20366 3 found2=true;
20367 3 foundlayer = i+1;
20368 //zprint("Found layer: %d \n", i);
20369 3 break;
20370 }
20371 14424017 }
20372 7212068 }
20373
20374
4/4
✓ Branch 0 taken 7212023 times.
✓ Branch 1 taken 999 times.
✓ Branch 2 taken 7212917 times.
✓ Branch 3 taken 105 times.
7213022 if(!(found1 || found2) || pushing<8)
20375 {
20376 7212917 return;
20377 }
20378
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 6 times.
105 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
20379
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 51 times.
105 if(!try_locked_combo(cmb3))
20380 51 return;
20381
20382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(cmb.usrflags&cflag16)
20383 {
20384 setxmapflag(1<<cmb.attribytes[5]);
20385 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20386 }
20387 else
20388 {
20389 54 setmapflag(mLOCKBLOCK);
20390 54 remove_lockblocks((currscr>=128)?1:0);
20391 }
20392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if ( cmb3.usrflags&cflag3 )
20393 {
20394 if ( (cmb3.attribytes[3]) )
20395 sfx(cmb3.attribytes[3]);
20396 }
20397 54 else sfx(WAV_DOOR);
20398 7227377 }
20399
20400 7227377 void HeroClass::oldcheckbosslockblock()
20401 {
20402
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 7213022 times.
7227377 if(toogam) return;
20403
20404 7213022 int32_t bx = x.getInt()&0xF0;
20405 7213022 int32_t bx2 = int32_t(x+8)&0xF0;
20406 7213022 int32_t by = y.getInt()&0xF0;
20407
20408
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1770315 times.
✓ Branch 2 taken 1381487 times.
✓ Branch 3 taken 1952663 times.
✓ Branch 4 taken 2108557 times.
7213022 switch(dir)
20409 {
20410 case up:
20411
4/4
✓ Branch 0 taken 320945 times.
✓ Branch 1 taken 1449370 times.
✓ Branch 2 taken 6412 times.
✓ Branch 3 taken 314533 times.
1770315 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20412
20413 1770315 break;
20414
20415 case down:
20416 1381487 by+=16;
20417 1381487 break;
20418
20419 case left:
20420
2/2
✓ Branch 0 taken 854879 times.
✓ Branch 1 taken 1097784 times.
1952663 if((((int32_t)x)&0x0F)<8)
20421 1097784 bx-=16;
20422
20423
2/2
✓ Branch 0 taken 1244259 times.
✓ Branch 1 taken 708404 times.
1952663 if(y.getInt()&8)
20424 {
20425 708404 by+=16;
20426 708404 }
20427
20428 1952663 bx2=bx;
20429 1952663 break;
20430
20431 case right:
20432 2108557 bx+=16;
20433
20434
2/2
✓ Branch 0 taken 1367211 times.
✓ Branch 1 taken 741346 times.
2108557 if(y.getInt()&8)
20435 {
20436 741346 by+=16;
20437 741346 }
20438
20439 2108557 bx2=bx;
20440 2108557 break;
20441 }
20442
20443
20444 7213022 bool found1 = false;
20445 7213022 bool found2 = false;
20446 7213022 int32_t foundlayer = -1;
20447 7213022 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
20448 7213022 newcombo const& cmb = combobuf[cid1];
20449 7213022 newcombo const& cmb2 = combobuf[cid2];
20450 // Layer 0 is overridden by Locked Doors
20451
5/8
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 7212542 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 480 times.
7213022 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
20452 {
20453 480 found1 = true;
20454 480 foundlayer = 0;
20455 480 }
20456
5/8
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7212533 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
7212542 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
20457 {
20458 9 found2 = true;
20459 9 foundlayer = 0;
20460 9 }
20461
20462
2/2
✓ Branch 0 taken 14426044 times.
✓ Branch 1 taken 7213022 times.
21639066 for (int32_t i = 0; i <= 1; ++i)
20463 {
20464
2/2
✓ Branch 0 taken 11714735 times.
✓ Branch 1 taken 2711309 times.
14426044 if (tmpscr2[i].valid != 0)
20465 {
20466
2/2
✓ Branch 0 taken 2603454 times.
✓ Branch 1 taken 107855 times.
2711309 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20467 {
20468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2603454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2603454 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2603454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2603454 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20470 2603454 }
20471 else
20472 {
20473
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
20474
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
20475 }
20476 2711309 }
20477 14426044 }
20478
20479
20480 // Layers
20481
4/4
✓ Branch 0 taken 7212542 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 7212533 times.
7213022 if (!(found1 || found2))
20482 {
20483 7212533 foundlayer = -1;
20484
2/2
✓ Branch 0 taken 7212533 times.
✓ Branch 1 taken 14425066 times.
21637599 for (int32_t i = 0; i < 2; i++)
20485 {
20486 14425066 cid1 = MAPCOMBO2(i, bx, by);
20487 14425066 cid2 = MAPCOMBO2(i, bx2, by);
20488 14425066 newcombo const& cmb = combobuf[cid1];
20489 14425066 newcombo const& cmb2 = combobuf[cid2];
20490
2/2
✓ Branch 0 taken 7212533 times.
✓ Branch 1 taken 7212533 times.
14425066 if (i == 0)
20491 {
20492
2/2
✓ Branch 0 taken 6235985 times.
✓ Branch 1 taken 976548 times.
7212533 if (tmpscr2[1].valid != 0)
20493 {
20494
2/2
✓ Branch 0 taken 931930 times.
✓ Branch 1 taken 44618 times.
976548 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20495 {
20496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931930 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 931930 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
931930 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20498 931930 }
20499 else
20500 {
20501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
20502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
20503 }
20504 976548 }
20505 7212533 }
20506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14425066 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14425066 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
20507 {
20508 found1 = true;
20509 foundlayer = i;
20510 break;
20511 }
20512
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14425066 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14425066 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
20513 {
20514 found2 = true;
20515 foundlayer = i;
20516 break;
20517 }
20518 14425066 }
20519 7212533 }
20520
20521
4/4
✓ Branch 0 taken 7212542 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 7212901 times.
✓ Branch 3 taken 121 times.
7213022 if (!(found1 || found2) || pushing < 8)
20522 {
20523 7212901 return;
20524 }
20525
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1 times.
121 int32_t cid = found1 ? cid1 : cid2;
20526
20527
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 108 times.
121 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20528
20529
20530 // Run Boss Key Script
20531 13 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 884 times.
884 for ( int32_t q = 0; q < MAXITEMS; ++q )
20533 {
20534
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 13 times.
884 if ( itemsbuf[q].family == itype_bosskey )
20535 {
20536 13 key_item = q; break;
20537 }
20538 871 }
20539
2/8
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
13 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
20540 {
20541 int i = key_item;
20542 FFCore.reset_script_engine_data(ScriptType::Item, i);
20543 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20544 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20545 }
20546
20547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(cmb.usrflags&cflag16)
20548 {
20549 setxmapflag(1<<cmb.attribytes[5]);
20550 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
20551 }
20552 else
20553 {
20554 13 setmapflag(mBOSSLOCKBLOCK);
20555 13 remove_bosslockblocks((currscr>=128)?1:0);
20556 }
20557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( (combobuf[cid].attribytes[3]) )
20558 13 sfx(combobuf[cid].attribytes[3]);
20559 7227377 }
20560
20561 21290262 void HeroClass::oldcheckchest(int32_t type)
20562 {
20563 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
20564
5/6
✓ Branch 0 taken 21250044 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 21240987 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21240987 times.
21290262 if(toogam || z>0 || fakez > 0) return;
20565
2/2
✓ Branch 0 taken 20293134 times.
✓ Branch 1 taken 947853 times.
21240987 if(pushing<8) return;
20566 947853 int32_t bx = x.getInt()&0xF0;
20567 947853 int32_t bx2 = int32_t(x+8)&0xF0;
20568 947853 int32_t by = y.getInt()&0xF0;
20569
20570
3/4
✓ Branch 0 taken 532377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192198 times.
✓ Branch 3 taken 223278 times.
947853 switch(dir)
20571 {
20572 case up:
20573
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 182526 times.
223278 if(isSideViewHero()) return;
20574
20575
4/4
✓ Branch 0 taken 56643 times.
✓ Branch 1 taken 125883 times.
✓ Branch 2 taken 55452 times.
✓ Branch 3 taken 1191 times.
182526 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
20576
20577 182526 break;
20578
20579 case left:
20580 case right:
20581
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 516204 times.
532377 if(isSideViewHero()) break;
20582 [[fallthrough]];
20583 case down:
20584 708402 return;
20585 }
20586
20587 198699 bool found=false;
20588 198699 bool itemflag=false;
20589
20590
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 198691 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
198699 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
20591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198691 times.
198691 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
20592 {
20593 8 found=true;
20594 8 }
20595
2/2
✓ Branch 0 taken 397398 times.
✓ Branch 1 taken 198699 times.
596097 for (int32_t i = 0; i <= 1; ++i)
20596 {
20597
2/2
✓ Branch 0 taken 336957 times.
✓ Branch 1 taken 60441 times.
397398 if(tmpscr2[i].valid!=0)
20598 {
20599
2/2
✓ Branch 0 taken 59580 times.
✓ Branch 1 taken 861 times.
60441 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20600 {
20601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59580 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59580 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20603 59580 }
20604 else
20605 {
20606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
20607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
20608 }
20609 60441 }
20610 397398 }
20611
20612
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 198691 times.
198699 if(!found)
20613 {
20614
2/2
✓ Branch 0 taken 198691 times.
✓ Branch 1 taken 397382 times.
596073 for(int32_t i=0; i<2; i++)
20615 {
20616
2/2
✓ Branch 0 taken 198691 times.
✓ Branch 1 taken 198691 times.
397382 if (i == 0)
20617 {
20618
2/2
✓ Branch 0 taken 181390 times.
✓ Branch 1 taken 17301 times.
198691 if(tmpscr2[1].valid!=0)
20619 {
20620
2/2
✓ Branch 0 taken 16920 times.
✓ Branch 1 taken 381 times.
17301 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20621 {
20622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16920 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16920 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16920 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20624 16920 }
20625 else
20626 {
20627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
20628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
20629 }
20630 17301 }
20631 198691 }
20632
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 397382 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
397382 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
20633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397382 times.
397382 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
20634 {
20635 found=true;
20636 break;
20637 }
20638 397382 }
20639 198691 }
20640
20641
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 198691 times.
198699 if(!found)
20642 {
20643 198691 return;
20644 }
20645
20646
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
20647 {
20648 case cLOCKEDCHEST:
20649 if(!usekey()) return;
20650
20651 setmapflag(mLOCKEDCHEST);
20652 break;
20653
20654 case cCHEST:
20655 8 setmapflag(mCHEST);
20656 8 break;
20657
20658 case cBOSSCHEST:
20659 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
20660 // Run Boss Key Script
20661 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
20662 for ( int32_t q = 0; q < MAXITEMS; ++q )
20663 {
20664 if ( itemsbuf[q].family == itype_bosskey )
20665 {
20666 key_item = q; break;
20667 }
20668 }
20669 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
20670 {
20671 int i = key_item;
20672 FFCore.reset_script_engine_data(ScriptType::Item, i);
20673 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
20674 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
20675 }
20676 setmapflag(mBOSSCHEST);
20677 break;
20678 }
20679
20680 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20681 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20682 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
20683 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
20684 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
20685 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
20686
20687
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
20688 {
20689 for(int32_t i=0; i<2; i++)
20690 {
20691 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
20692 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
20693 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
20694 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
20695 }
20696 }
20697
20698
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
20699 {
20700
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
20701 8 }
20702 21290262 }
20703
20704 515743 void HeroClass::checkchest(int32_t type)
20705 {
20706
4/4
✓ Branch 0 taken 360348 times.
✓ Branch 1 taken 155395 times.
✓ Branch 2 taken 155395 times.
✓ Branch 3 taken 204953 times.
515743 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
20707
2/2
✓ Branch 0 taken 24779 times.
✓ Branch 1 taken 490964 times.
515743 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
20708
2/2
✓ Branch 0 taken 24779 times.
✓ Branch 1 taken 490964 times.
515743 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
20709
2/2
✓ Branch 0 taken 24779 times.
✓ Branch 1 taken 490964 times.
515743 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
20710
2/2
✓ Branch 0 taken 49558 times.
✓ Branch 1 taken 466185 times.
515743 if(ischest)
20711 {
20712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 466185 times.
466185 if(get_qr(qr_OLD_CHEST_COLLISION))
20713 {
20714 oldcheckchest(type);
20715 return;
20716 }
20717 466185 }
20718
3/4
✓ Branch 0 taken 49558 times.
✓ Branch 1 taken 466185 times.
✓ Branch 2 taken 49558 times.
✗ Branch 3 not taken.
515743 if(islockblock && get_qr(qr_OLD_LOCKBLOCK_COLLISION))
20719 {
20720 if(type == cLOCKBLOCK)
20721 oldchecklockblock();
20722 else if(type == cBOSSLOCKBLOCK)
20723 oldcheckbosslockblock();
20724 return;
20725 }
20726
5/6
✓ Branch 0 taken 512896 times.
✓ Branch 1 taken 2847 times.
✓ Branch 2 taken 508940 times.
✓ Branch 3 taken 3956 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 508940 times.
515743 if(toogam || z>0 || fakez > 0) return;
20727 508940 zfix bx, by;
20728 508940 zfix bx2, by2;
20729 508940 zfix fx(-1), fy(-1);
20730
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 109713 times.
✓ Branch 2 taken 115540 times.
✓ Branch 3 taken 129574 times.
✓ Branch 4 taken 154113 times.
508940 switch(dir)
20731 {
20732 case up:
20733 109713 by = y + (bigHitbox ? -2 : 6);
20734 109713 by2 = by;
20735 109713 bx = x + 4;
20736 109713 bx2 = bx + 8;
20737 109713 break;
20738 case down:
20739 115540 by = y + 17;
20740 115540 by2 = by;
20741 115540 bx = x + 4;
20742 115540 bx2 = bx + 8;
20743 115540 break;
20744 case left:
20745 129574 by = y + (bigHitbox ? 0 : 8);
20746 129574 by2 = y + 8;
20747 129574 bx = x - 2;
20748 129574 bx2 = x - 2;
20749 129574 break;
20750 case right:
20751 154113 by = y + (bigHitbox ? 0 : 8);
20752 154113 by2 = y + 8;
20753 154113 bx = x + 17;
20754 154113 bx2 = x + 17;
20755 154113 break;
20756 }
20757
20758 508940 int32_t found = -1;
20759 508940 int32_t foundlayer = 0;
20760
20761 508940 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
20762
20763
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 508069 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
508940 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
20764 {
20765 871 found = MAPCOMBO(bx,by);
20766 871 fx = bx; fy = by;
20767
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
20768 {
20769
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
20770 {
20771
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20772 {
20773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20774 1357 }
20775 else
20776 {
20777 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
20778 }
20779 1357 }
20780 1742 }
20781 871 }
20782
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 508069 times.
508940 if(found<0)
20783 {
20784 508069 cmb = &combobuf[MAPCOMBO(bx2,by2)];
20785
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 508046 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
508069 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
20786 {
20787 23 found = MAPCOMBO(bx2,by2);
20788
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
20789 {
20790
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
20791 {
20792
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20793 {
20794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
20795 {
20796 found = -1;
20797 break;
20798 }
20799 46 }
20800 else
20801 {
20802 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
20803 {
20804 found = -1;
20805 break;
20806 }
20807 }
20808 46 }
20809 161 }
20810
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
20811 {
20812 23 fx = bx2; fy = by2;
20813 23 }
20814 23 }
20815 508069 }
20816
20817
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 508046 times.
508940 if(found<0)
20818 {
20819
2/2
✓ Branch 0 taken 507993 times.
✓ Branch 1 taken 3048011 times.
3556004 for(int32_t i=0; i<6; i++)
20820 {
20821 3048011 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
20822
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3047958 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
3048011 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
20823 {
20824 53 found = MAPCOMBO2(i,bx,by);
20825
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
20826 {
20827
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
20828 {
20829
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20830 {
20831
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
20832 {
20833 found = -1;
20834 break;
20835 }
20836 53 }
20837 else
20838 {
20839 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
20840 {
20841 found = -1;
20842 break;
20843 }
20844 }
20845 53 }
20846 265 }
20847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
20848 {
20849 53 foundlayer = i+1;
20850 53 fx = bx; fy = by;
20851 53 break;
20852 }
20853 }
20854 3047958 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
20855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3047958 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3047958 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
20856 {
20857 found = MAPCOMBO2(i,bx2,by2);
20858 for(int32_t j = i+1; j < 6; ++j)
20859 {
20860 if (tmpscr2[j].valid!=0)
20861 {
20862 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20863 {
20864 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
20865 {
20866 found = -1;
20867 break;
20868 }
20869 }
20870 else
20871 {
20872 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
20873 {
20874 found = -1;
20875 break;
20876 }
20877 }
20878 }
20879 }
20880 if(found>-1)
20881 {
20882 foundlayer = i+1;
20883 fx = bx2; fy = by2;
20884 break;
20885 }
20886 }
20887 3047958 }
20888 508046 }
20889
20890
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 507993 times.
508940 if(found<0) return;
20891 947 cmb = &combobuf[found];
20892
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
20893 {
20894 case up:
20895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
20896 return;
20897 947 break;
20898 case down:
20899 if(cmb->usrflags&cflag9)
20900 return;
20901 break;
20902 case left:
20903 if(cmb->usrflags&cflag12)
20904 return;
20905 break;
20906 case right:
20907 if(cmb->usrflags&cflag11)
20908 return;
20909 break;
20910 }
20911 947 int32_t intbtn = cmb->attribytes[2];
20912
20913
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
20914 {
20915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
20916 {
20917 947 int altcmb = cmb->attributes[2]/10000;
20918 947 prompt_combo = cmb->attributes[1]/10000;
20919
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
20920 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
20921 prompt_combo = altcmb;
20922 947 prompt_cset = cmb->attribytes[4];
20923 947 prompt_x = cmb->attrishorts[0];
20924 947 prompt_y = cmb->attrishorts[1];
20925 947 }
20926
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
20927 {
20928 935 return; //Button not pressed
20929 }
20930 12 }
20931 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
20932
20933
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
20934 {
20935
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
20936 12 }
20937 else if(islockblock)
20938 {
20939 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
20940 }
20941
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
20942 12 prompt_combo = 0;
20943 515743 }
20944
20945 7262873 void HeroClass::checkgenpush()
20946 {
20947
4/4
✓ Branch 0 taken 320344 times.
✓ Branch 1 taken 6942529 times.
✓ Branch 2 taken 47066 times.
✓ Branch 3 taken 273278 times.
7262873 if(pushing < 8 || pushing % 8) return;
20948 47066 zfix bx, by;
20949 47066 zfix bx2, by2;
20950
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11243 times.
✓ Branch 2 taken 9807 times.
✓ Branch 3 taken 12388 times.
✓ Branch 4 taken 13628 times.
47066 switch(dir)
20951 {
20952 case up:
20953 11243 by = y + (bigHitbox ? -2 : 6);
20954 11243 by2 = by;
20955 11243 bx = x + 4;
20956 11243 bx2 = bx + 8;
20957 11243 break;
20958 case down:
20959 9807 by = y + 17;
20960 9807 by2 = by;
20961 9807 bx = x + 4;
20962 9807 bx2 = bx + 8;
20963 9807 break;
20964 case left:
20965 12388 by = y + (bigHitbox ? 0 : 8);
20966 12388 by2 = y + 8;
20967 12388 bx = x - 2;
20968 12388 bx2 = x - 2;
20969 12388 break;
20970 case right:
20971 13628 by = y + (bigHitbox ? 0 : 8);
20972 13628 by2 = y + 8;
20973 13628 bx = x + 17;
20974 13628 bx2 = x + 17;
20975 13628 break;
20976 }
20977 47066 auto pos1 = COMBOPOS(bx,by);
20978 47066 auto pos2 = COMBOPOS(bx2,by2);
20979
2/2
✓ Branch 0 taken 329462 times.
✓ Branch 1 taken 47066 times.
376528 for(auto layer = 0; layer < 7; ++layer)
20980 {
20981 329462 mapscr* tmp = FFCore.tempScreens[layer];
20982
20983 329462 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
20984
2/2
✓ Branch 0 taken 329461 times.
✓ Branch 1 taken 1 times.
329462 if(cmb1.triggerflags[1] & combotriggerPUSH)
20985 1 do_trigger_combo(layer,pos1);
20986
20987
2/2
✓ Branch 0 taken 275156 times.
✓ Branch 1 taken 54306 times.
329462 if(pos1==pos2) continue;
20988
20989 54306 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
20990
1/2
✓ Branch 0 taken 54306 times.
✗ Branch 1 not taken.
54306 if(cmb2.triggerflags[1] & combotriggerPUSH)
20991 do_trigger_combo(layer,pos2);
20992 54306 }
20993
2/2
✓ Branch 0 taken 46306 times.
✓ Branch 1 taken 760 times.
47066 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
20994 {
20995 760 word c = tmpscr->numFFC();
20996
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 4340 times.
5100 for(word i=0; i<c; i++)
20997 {
20998
4/4
✓ Branch 0 taken 4288 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 4280 times.
4340 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
20999 {
21000 60 ffcdata& ffc = tmpscr->ffcs[i];
21001 60 newcombo const& cmb3 = combobuf[ffc.getData()];
21002
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(cmb3.triggerflags[1] & combotriggerPUSH)
21003 {
21004 do_trigger_combo_ffc(i);
21005 break;
21006 }
21007 60 }
21008 4340 }
21009 760 }
21010 7262873 }
21011
21012 7262874 void HeroClass::checksigns() //Also checks for generic trigger buttons
21013 {
21014
5/6
✓ Branch 0 taken 7248519 times.
✓ Branch 1 taken 14355 times.
✓ Branch 2 taken 7244602 times.
✓ Branch 3 taken 3917 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7244602 times.
7262874 if(toogam || z>0 || fakez>0) return;
21015
5/6
✓ Branch 0 taken 7195605 times.
✓ Branch 1 taken 48997 times.
✓ Branch 2 taken 180362 times.
✓ Branch 3 taken 7015243 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 180362 times.
7244602 if(msg_active || (msg_onscreen && get_qr(qr_MSGDISAPPEAR)))
21016 48997 return; //Don't overwrite a message waiting to be dismissed
21017 7195605 zfix bx, by;
21018 7195605 zfix bx2, by2;
21019 7195605 zfix fx(-1), fy(-1);
21020
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1734175 times.
✓ Branch 2 taken 1384917 times.
✓ Branch 3 taken 1953890 times.
✓ Branch 4 taken 2122623 times.
7195605 switch(dir)
21021 {
21022 case up:
21023 1734175 by = y + (bigHitbox ? -2 : 6);
21024 1734175 by2 = by;
21025 1734175 bx = x + 4;
21026 1734175 bx2 = bx + 8;
21027 1734175 break;
21028 case down:
21029 1384917 by = y + 17;
21030 1384917 by2 = by;
21031 1384917 bx = x + 4;
21032 1384917 bx2 = bx + 8;
21033 1384917 break;
21034 case left:
21035 1953890 by = y + (bigHitbox ? 0 : 8);
21036 1953890 by2 = y + 8;
21037 1953890 bx = x - 2;
21038 1953890 bx2 = x - 2;
21039 1953890 break;
21040 case right:
21041 2122623 by = y + (bigHitbox ? 0 : 8);
21042 2122623 by2 = y + 8;
21043 2122623 bx = x + 17;
21044 2122623 bx2 = x + 17;
21045 2122623 break;
21046 }
21047
21048 7195605 int32_t found = -1;
21049 7195605 int32_t foundffc = -1;
21050 7195605 int32_t found_lyr = 0;
21051 7195605 bool found_sign = false;
21052 7195605 int32_t tmp_cid = MAPCOMBO(bx,by);
21053 7195605 newcombo const* tmp_cmb = &combobuf[tmp_cid];
21054
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7195605 times.
✓ Branch 2 taken 7194959 times.
✓ Branch 3 taken 646 times.
14391210 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21055 7195605 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
21056 {
21057 646 found = tmp_cid;
21058 646 fx = bx; fy = by;
21059
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 646 times.
1938 for (int32_t i = 0; i <= 1; ++i)
21060 {
21061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if(tmpscr2[i].valid!=0)
21062 {
21063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21064 {
21065 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
21066 }
21067 else
21068 {
21069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1292 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
21070 }
21071 1292 }
21072 1292 }
21073 646 }
21074 7195605 tmp_cid = MAPCOMBO(bx2,by2);
21075 7195605 tmp_cmb = &combobuf[tmp_cid];
21076
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7195605 times.
✓ Branch 2 taken 7195019 times.
✓ Branch 3 taken 586 times.
14391210 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21077 7195605 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
21078 {
21079 586 found = tmp_cid;
21080 586 fx = bx2; fy = by2;
21081
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 586 times.
1758 for (int32_t i = 0; i <= 1; ++i)
21082 {
21083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if(tmpscr2[i].valid!=0)
21084 {
21085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21086 {
21087 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
21088 }
21089 else
21090 {
21091
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
21092 }
21093 1172 }
21094 1172 }
21095 586 }
21096
21097
2/2
✓ Branch 0 taken 7042598 times.
✓ Branch 1 taken 153007 times.
7195605 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
21098 {
21099 153007 word c = tmpscr->numFFC();
21100
2/2
✓ Branch 0 taken 153007 times.
✓ Branch 1 taken 629871 times.
782878 for(word i=0; i<c; i++)
21101 {
21102
4/4
✓ Branch 0 taken 624110 times.
✓ Branch 1 taken 5761 times.
✓ Branch 2 taken 463 times.
✓ Branch 3 taken 623647 times.
629871 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
21103 {
21104 6224 ffcdata& ffc = tmpscr->ffcs[i];
21105 6224 tmp_cmb = &combobuf[ffc.getData()];
21106
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6224 times.
6224 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21107 6224 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
21108 {
21109 foundffc = i;
21110 break;
21111 }
21112 6224 }
21113 629871 }
21114 153007 }
21115
21116
3/4
✓ Branch 0 taken 7194956 times.
✓ Branch 1 taken 649 times.
✓ Branch 2 taken 7194956 times.
✗ Branch 3 not taken.
7195605 if(found<0 && foundffc < 0)
21117 {
21118
2/2
✓ Branch 0 taken 7194384 times.
✓ Branch 1 taken 43166876 times.
50361260 for(int32_t i=0; i<6; i++)
21119 {
21120 43166876 tmp_cid = MAPCOMBO2(i,bx,by);
21121 43166876 tmp_cmb = &combobuf[tmp_cid];
21122
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43166876 times.
✓ Branch 2 taken 43166304 times.
✓ Branch 3 taken 572 times.
86333752 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21123 43166876 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
21124 {
21125 572 found = tmp_cid;
21126 572 found_lyr = i+1;
21127 572 fx = bx; fy = by;
21128
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
21129 {
21130
1/2
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
440 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21131 {
21132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
21133 440 }
21134 else
21135 {
21136 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
21137 }
21138 440 }
21139 572 }
21140 43166876 tmp_cid = MAPCOMBO2(i,bx2,by2);
21141 43166876 tmp_cmb = &combobuf[tmp_cid];
21142
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43166876 times.
✓ Branch 2 taken 43166360 times.
✓ Branch 3 taken 516 times.
86333752 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
21143 43166876 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
21144 {
21145 516 found = tmp_cid;
21146 516 found_lyr = i+1;
21147 516 fx = bx2; fy = by2;
21148
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
21149 {
21150
1/2
✓ Branch 0 taken 390 times.
✗ Branch 1 not taken.
390 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21151 {
21152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21153 390 }
21154 else
21155 {
21156 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
21157 }
21158 390 }
21159 516 }
21160
2/2
✓ Branch 0 taken 43166304 times.
✓ Branch 1 taken 572 times.
43166876 if(found>-1) break;
21161 43166304 }
21162 7194956 }
21163
21164
3/4
✓ Branch 0 taken 7194384 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 7194384 times.
✗ Branch 3 not taken.
7195605 if(found<0&&foundffc<0) return;
21165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
21166
21167 1221 byte signInput = 0;
21168 1221 bool didsign = false, didprompt = false;
21169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1221 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
21170 {
21171 switch(dir)
21172 {
21173 case up:
21174 if(cmb.usrflags&cflag10)
21175 goto endsigns;
21176 break;
21177 case down:
21178 if(cmb.usrflags&cflag9)
21179 goto endsigns;
21180 break;
21181 case left:
21182 if(cmb.usrflags&cflag12)
21183 goto endsigns;
21184 break;
21185 case right:
21186 if(cmb.usrflags&cflag11)
21187 goto endsigns;
21188 break;
21189 }
21190 int32_t intbtn = cmb.attribytes[2];
21191
21192 if(intbtn) //
21193 {
21194 signInput = getIntBtnInput(intbtn, true, true, false, false);
21195 if(!signInput)
21196 {
21197 if(cmb.usrflags & cflag13) //display prompt
21198 {
21199 prompt_combo = cmb.attributes[1]/10000;
21200 prompt_cset = cmb.attribytes[4];
21201 prompt_x = cmb.attrishorts[0];
21202 prompt_y = cmb.attrishorts[1];
21203 didprompt = true;
21204 }
21205 goto endsigns; //Button not pressed
21206 }
21207 }
21208 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
21209
21210 trigger_sign(cmb);
21211 didsign = true;
21212 }
21213 endsigns:
21214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
21215
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 431 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 228 times.
1221 switch(dir)
21216 {
21217 case down:
21218
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
21219 return;
21220 253 break;
21221 case up:
21222
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
21223 return;
21224 431 break;
21225 case right:
21226
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
21227 return;
21228 309 break;
21229 case left:
21230
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 75 times.
228 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
21231 75 return;
21232 153 break;
21233 }
21234
4/6
✓ Branch 0 taken 1146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1114 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1114 times.
1146 if(cmb.triggerbtn && (getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput)))
21235 {
21236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (foundffc >= 0)
21237 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
21238 else
21239 32 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
21240 32 }
21241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(didprompt)
21242 return;
21243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.type == cBUTTONPROMPT)
21244 {
21245 prompt_combo = cmb.attributes[0]/10000;
21246 prompt_cset = cmb.attribytes[0];
21247 prompt_x = cmb.attrishorts[0];
21248 prompt_y = cmb.attrishorts[1];
21249 }
21250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.prompt_cid)
21251 {
21252 1114 prompt_combo = cmb.prompt_cid;
21253 1114 prompt_cset = cmb.prompt_cs;
21254 1114 prompt_x = cmb.prompt_x;
21255 1114 prompt_y = cmb.prompt_y;
21256 1114 }
21257 7262874 }
21258
21259 7252157 void HeroClass::checklocked()
21260 {
21261
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 7237802 times.
7252157 if(toogam) return; //Walk through walls.
21262
21263
2/2
✓ Branch 0 taken 3719906 times.
✓ Branch 1 taken 3517896 times.
7237802 if(!isdungeon()) return;
21264
21265
4/4
✓ Branch 0 taken 3719268 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 7791 times.
✓ Branch 3 taken 3711477 times.
3719906 if( !diagonalMovement && pushing!=8) return;
21266 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
21267 */
21268
4/4
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 7791 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 628 times.
8429 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
21269
21270
21271 7801 bool found = false;
21272
2/2
✓ Branch 0 taken 31204 times.
✓ Branch 1 taken 7801 times.
39005 for ( int32_t q = 0; q < 4; q++ ) {
21273
4/4
✓ Branch 0 taken 30476 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 30230 times.
31204 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
21274 31204 }
21275
21276
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 6858 times.
7801 if ( !found ) return;
21277
21278 943 int32_t si = (currmap<<7) + currscr;
21279 943 int32_t di = 0;
21280
21281
21282
21283
2/4
✓ Branch 0 taken 943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 943 times.
943 if ( diagonalMovement || get_qr(qr_DISABLE_4WAY_GRIDLOCK))
21284 {
21285 //Up door
21286 if ( y <= 32 && x >= 112 && x <= 128 )
21287 {
21288 if (
21289 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
21290
21291 )
21292 {
21293 di = nextscr(up);
21294 if(tmpscr->door[0]==dLOCKED)
21295 {
21296 if(usekey())
21297 {
21298 putdoor(scrollbuf,0,up,dUNLOCKED);
21299 tmpscr->door[0]=dUNLOCKED;
21300 setmapflag(si, mDOOR_UP);
21301
21302 if(di != 0xFFFF)
21303 setmapflag(di, mDOOR_DOWN);
21304 sfx(WAV_DOOR);
21305 markBmap(-1);
21306 }
21307 else return;
21308 }
21309 else if(tmpscr->door[0]==dBOSS)
21310 {
21311 if(game->lvlitems[dlevel]&liBOSSKEY)
21312 {
21313 putdoor(scrollbuf,0,up,dOPENBOSS);
21314 tmpscr->door[0]=dOPENBOSS;
21315 setmapflag(si, mDOOR_UP);
21316
21317 if(di != 0xFFFF)
21318 setmapflag(di, mDOOR_DOWN);
21319 sfx(WAV_DOOR);
21320 markBmap(-1);
21321 // Run Boss Key Script
21322 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21323 for ( int32_t q = 0; q < MAXITEMS; ++q )
21324 {
21325 if ( itemsbuf[q].family == itype_bosskey )
21326 {
21327 key_item = q; break;
21328 }
21329 }
21330 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21331 {
21332 int i = key_item;
21333 FFCore.reset_script_engine_data(ScriptType::Item, i);
21334 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21335 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21336 }
21337 }
21338 else return;
21339
21340 }
21341
21342 }
21343 }
21344 //Down
21345 if ( y >= 128 && x >= 112 && x <= 128 )
21346 {
21347 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
21348 {
21349 di = nextscr(down);
21350 if(tmpscr->door[1]==dLOCKED)
21351 {
21352 if(usekey())
21353 {
21354 putdoor(scrollbuf,0,down,dUNLOCKED);
21355 tmpscr->door[1]=dUNLOCKED;
21356 setmapflag(si, mDOOR_DOWN);
21357
21358 if(di != 0xFFFF)
21359 setmapflag(di, mDOOR_UP);
21360 sfx(WAV_DOOR);
21361 markBmap(-1);
21362 }
21363 else return;
21364 }
21365 else if(tmpscr->door[1]==dBOSS)
21366 {
21367 if(game->lvlitems[dlevel]&liBOSSKEY)
21368 {
21369 putdoor(scrollbuf,0,down,dOPENBOSS);
21370 tmpscr->door[1]=dOPENBOSS;
21371 setmapflag(si, mDOOR_DOWN);
21372
21373 if(di != 0xFFFF)
21374 setmapflag(di, mDOOR_UP);
21375 sfx(WAV_DOOR);
21376 markBmap(-1);
21377 // Run Boss Key Script
21378 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21379 for ( int32_t q = 0; q < MAXITEMS; ++q )
21380 {
21381 if ( itemsbuf[q].family == itype_bosskey )
21382 {
21383 key_item = q; break;
21384 }
21385 }
21386 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21387 {
21388 int i = key_item;
21389 FFCore.reset_script_engine_data(ScriptType::Item, i);
21390 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21391 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21392 }
21393 }
21394 else return;
21395 }
21396 }
21397 }
21398 //left
21399 if ( y > 72 && y < 88 && x <= 32 )
21400 {
21401 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
21402 {
21403 di = nextscr(left);
21404 if(tmpscr->door[2]==dLOCKED)
21405 {
21406 if(usekey())
21407 {
21408 putdoor(scrollbuf,0,left,dUNLOCKED);
21409 tmpscr->door[2]=dUNLOCKED;
21410 setmapflag(si, mDOOR_LEFT);
21411
21412 if(di != 0xFFFF)
21413 setmapflag(di, mDOOR_RIGHT);
21414 sfx(WAV_DOOR);
21415 markBmap(-1);
21416 }
21417 else return;
21418 }
21419 else if(tmpscr->door[2]==dBOSS)
21420 {
21421 if(game->lvlitems[dlevel]&liBOSSKEY)
21422 {
21423 putdoor(scrollbuf,0,left,dOPENBOSS);
21424 tmpscr->door[2]=dOPENBOSS;
21425 setmapflag(si, mDOOR_LEFT);
21426
21427 if(di != 0xFFFF)
21428 setmapflag(di, mDOOR_RIGHT);
21429 sfx(WAV_DOOR);
21430 markBmap(-1);
21431 // Run Boss Key Script
21432 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21433 for ( int32_t q = 0; q < MAXITEMS; ++q )
21434 {
21435 if ( itemsbuf[q].family == itype_bosskey )
21436 {
21437 key_item = q; break;
21438 }
21439 }
21440 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21441 {
21442 int i = key_item;
21443 FFCore.reset_script_engine_data(ScriptType::Item, i);
21444 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21445 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21446 }
21447 }
21448 else return;
21449 }
21450 }
21451 }
21452
21453
21454 //right
21455 if ( ( y > 72 && y < 88 ) && x >= 208 )
21456 //!( (y<=72||y>=88) && x<206 ) )
21457 //y<=72||y>=88):y!=80) || x<208)
21458 {
21459 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
21460 {
21461 di = nextscr(right);
21462 if(tmpscr->door[right]==dLOCKED)
21463 {
21464 if(usekey())
21465 {
21466 putdoor(scrollbuf,0,right,dUNLOCKED);
21467 tmpscr->door[3]=dUNLOCKED;
21468 setmapflag(si, mDOOR_RIGHT);
21469
21470 if(di != 0xFFFF)
21471 setmapflag(di, mDOOR_LEFT);
21472 sfx(WAV_DOOR);
21473 markBmap(-1);
21474 }
21475 else return;
21476 }
21477 else if(tmpscr->door[right]==dBOSS)
21478 {
21479 if(game->lvlitems[dlevel]&liBOSSKEY)
21480 {
21481 putdoor(scrollbuf,0,right,dOPENBOSS);
21482 tmpscr->door[3]=dOPENBOSS;
21483 setmapflag(si, mDOOR_RIGHT);
21484
21485 if(di != 0xFFFF)
21486 setmapflag(di, mDOOR_LEFT);
21487 sfx(WAV_DOOR);
21488 markBmap(-1);
21489 // Run Boss Key Script
21490 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21491 for ( int32_t q = 0; q < MAXITEMS; ++q )
21492 {
21493 if ( itemsbuf[q].family == itype_bosskey )
21494 {
21495 key_item = q; break;
21496 }
21497 }
21498 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21499 {
21500 int i = key_item;
21501 FFCore.reset_script_engine_data(ScriptType::Item, i);
21502 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21503 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21504 }
21505 }
21506 else return;
21507 }
21508
21509 }
21510 }
21511 }
21512 else
21513 {
21514 //orthogonal movement
21515 //Up door
21516
4/4
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 746 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 118 times.
943 if ( y<=32 && x == 120 )
21517 //!( y>32 && (x!=120) ))
21518 {
21519
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 1 times.
118 switch ( dir )
21520 {
21521 case up:
21522 case r_up:
21523 case l_up:
21524 {
21525 117 di = nextscr(up);
21526
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 26 times.
117 if(tmpscr->door[0]==dLOCKED)
21527 {
21528
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(usekey())
21529 {
21530 88 putdoor(scrollbuf,0,up,dUNLOCKED);
21531 88 tmpscr->door[0]=dUNLOCKED;
21532 88 setmapflag(si, mDOOR_UP);
21533
21534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(di != 0xFFFF)
21535 88 setmapflag(di, mDOOR_DOWN);
21536 88 sfx(WAV_DOOR);
21537 88 markBmap(-1);
21538 88 }
21539 3 else return;
21540 88 }
21541
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15 times.
26 else if(tmpscr->door[0]==dBOSS)
21542 {
21543
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
21544 {
21545 14 putdoor(scrollbuf,0,up,dOPENBOSS);
21546 14 tmpscr->door[0]=dOPENBOSS;
21547 14 setmapflag(si, mDOOR_UP);
21548
21549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
21550 14 setmapflag(di, mDOOR_DOWN);
21551 14 sfx(WAV_DOOR);
21552 14 markBmap(-1);
21553 // Run Boss Key Script
21554 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
21556 {
21557
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
21558 {
21559 14 key_item = q; break;
21560 }
21561 938 }
21562
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21563 {
21564 int i = key_item;
21565 FFCore.reset_script_engine_data(ScriptType::Item, i);
21566 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21567 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21568 }
21569 14 }
21570 1 else return;
21571 14 }
21572 113 break;
21573 }
21574 1 default: break;
21575
21576 }
21577 114 }
21578 //Down
21579
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 38 times.
939 if ( y >= 128 && x == 120 )
21580 //!(y<128 && (x!=120) ) )
21581 {
21582
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 3 times.
38 switch(dir)
21583 {
21584 case down:
21585 case l_down:
21586 case r_down:
21587 {
21588 35 di = nextscr(down);
21589
21590
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(tmpscr->door[1]==dLOCKED)
21591 {
21592
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if(usekey())
21593 {
21594 23 putdoor(scrollbuf,0,down,dUNLOCKED);
21595 23 tmpscr->door[1]=dUNLOCKED;
21596 23 setmapflag(si, mDOOR_DOWN);
21597
21598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(di != 0xFFFF)
21599 23 setmapflag(di, mDOOR_UP);
21600 23 sfx(WAV_DOOR);
21601 23 markBmap(-1);
21602 23 }
21603 1 else return;
21604 23 }
21605
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 else if(tmpscr->door[1]==dBOSS)
21606 {
21607
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21608 {
21609 4 putdoor(scrollbuf,0,down,dOPENBOSS);
21610 4 tmpscr->door[1]=dOPENBOSS;
21611 4 setmapflag(si, mDOOR_DOWN);
21612
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21614 4 setmapflag(di, mDOOR_UP);
21615 4 sfx(WAV_DOOR);
21616 4 markBmap(-1);
21617 // Run Boss Key Script
21618 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21620 {
21621
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21622 {
21623 4 key_item = q; break;
21624 }
21625 268 }
21626
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21627 {
21628 int i = key_item;
21629 FFCore.reset_script_engine_data(ScriptType::Item, i);
21630 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21631 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21632 }
21633 4 }
21634 1 else return;
21635 4 }
21636 33 break;
21637 }
21638 3 default: break;
21639 }
21640 36 }
21641 //left
21642
4/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 58 times.
937 if ( y == 80 && x <= 32 )
21643 //!( (y!=80) && x>32 ) )
21644 {
21645
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 9 times.
58 switch(dir)
21646 {
21647 case left:
21648 case l_up:
21649 case l_down:
21650 {
21651 49 di = nextscr(left);
21652
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 14 times.
49 if(tmpscr->door[2]==dLOCKED)
21653 {
21654
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 if(usekey())
21655 {
21656 33 putdoor(scrollbuf,0,left,dUNLOCKED);
21657 33 tmpscr->door[2]=dUNLOCKED;
21658 33 setmapflag(si, mDOOR_LEFT);
21659
21660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(di != 0xFFFF)
21661 33 setmapflag(di, mDOOR_RIGHT);
21662 33 sfx(WAV_DOOR);
21663 33 markBmap(-1);
21664 33 }
21665 2 else return;
21666 33 }
21667
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 else if(tmpscr->door[2]==dBOSS)
21668 {
21669
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
21670 {
21671 4 putdoor(scrollbuf,0,left,dOPENBOSS);
21672 4 tmpscr->door[2]=dOPENBOSS;
21673 4 setmapflag(si, mDOOR_LEFT);
21674
21675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
21676 4 setmapflag(di, mDOOR_RIGHT);
21677 4 sfx(WAV_DOOR);
21678 4 markBmap(-1);
21679 // Run Boss Key Script
21680 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
21682 {
21683
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
21684 {
21685 4 key_item = q; break;
21686 }
21687 268 }
21688
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21689 {
21690 int i = key_item;
21691 FFCore.reset_script_engine_data(ScriptType::Item, i);
21692 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21693 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21694 }
21695 4 }
21696 1 else return;
21697 4 }
21698
21699 46 break;
21700
21701 }
21702 9 default: break;
21703 }
21704 55 }
21705 //right
21706
4/4
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 749 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 73 times.
934 if ( y == 80 && x >= 208 )
21707 //!((y!=80) && x<208 ) )
21708 {
21709
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 4 times.
73 switch(dir)
21710 {
21711 case right:
21712 case r_down:
21713 case r_up:
21714 {
21715 69 di = nextscr(right);
21716
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 19 times.
69 if(tmpscr->door[3]==dLOCKED)
21717 {
21718
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 4 times.
50 if(usekey())
21719 {
21720 46 putdoor(scrollbuf,0,right,dUNLOCKED);
21721 46 tmpscr->door[3]=dUNLOCKED;
21722 46 setmapflag(si, mDOOR_RIGHT);
21723
21724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(di != 0xFFFF)
21725 46 setmapflag(di, mDOOR_LEFT);
21726 46 sfx(WAV_DOOR);
21727 46 markBmap(-1);
21728 46 }
21729 4 else return;
21730 46 }
21731
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
19 else if(tmpscr->door[3]==dBOSS)
21732 {
21733
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
21734 {
21735 7 putdoor(scrollbuf,0,right,dOPENBOSS);
21736 7 tmpscr->door[3]=dOPENBOSS;
21737 7 setmapflag(si, mDOOR_RIGHT);
21738
21739
21740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
21741 7 setmapflag(di, mDOOR_LEFT);
21742 7 sfx(WAV_DOOR);
21743 7 markBmap(-1);
21744 // Run Boss Key Script
21745 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
21746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
21747 {
21748
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
21749 {
21750 7 key_item = q; break;
21751 }
21752 469 }
21753
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //
21754 {
21755 int i = key_item;
21756 FFCore.reset_script_engine_data(ScriptType::Item, i);
21757 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21758 FFCore.deallocateAllArrays(ScriptType::Item,(key_item));
21759 }
21760
21761 7 }
21762 1 else return;
21763 7 }
21764
21765
21766 64 break;
21767 }
21768 4 default: break;
21769
21770 }
21771 68 }
21772 }
21773 7252157 }
21774
21775 7252157 void HeroClass::checkswordtap()
21776 {
21777
6/6
✓ Branch 0 taken 3292585 times.
✓ Branch 1 taken 3959572 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 3290672 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
7252157 if(attack!=wSword || charging<=0 || pushing<8) return;
21778
21779 11 int32_t bx=x;
21780 11 int32_t by=y+8;
21781
21782
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
21783 {
21784 case up:
21785
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
21786
21787 11 by-=16;
21788 11 break;
21789
21790 case down:
21791 if(!Down()) return;
21792
21793 by+=16;
21794 bx+=8;
21795 break;
21796
21797 case left:
21798 if(!Left()) return;
21799
21800 bx-=16;
21801 by+=8;
21802 break;
21803
21804 case right:
21805 if(!Right()) return;
21806
21807 bx+=16;
21808 by+=8;
21809 break;
21810 }
21811
21812
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
21813
21814 11 attackclk=SWORDTAPFRAME;
21815 11 pushing=-8; //16 frames between taps
21816 11 tapping=true;
21817
21818 11 int32_t type = COMBOTYPE(bx,by);
21819
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
21821 {
21822
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
21823
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
21824
21825 // Layers
21826
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
21827
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
21828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
21829
21830
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
21831
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
21832 switch(i)
21833 {
21834 case up:
21835 case down:
21836 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
21837
21838 break;
21839
21840 case left:
21841 case right:
21842 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
21843
21844 break;
21845 }
21846
21847 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
21848 11 }
21849
21850 7252157 }
21851
21852 22208 void HeroClass::fairycircle(int32_t type)
21853 {
21854
2/2
✓ Branch 0 taken 18756 times.
✓ Branch 1 taken 3452 times.
22208 if(fairyclk==0)
21855 {
21856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3452 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3452 switch(type)
21857 {
21858 case REFILL_LIFE:
21859
2/2
✓ Branch 0 taken 3326 times.
✓ Branch 1 taken 126 times.
3452 if(didstuff&did_fairy) return;
21860
21861 126 didstuff|=did_fairy;
21862 126 break;
21863
21864 case REFILL_MAGIC:
21865 if(didstuff&did_magic) return;
21866
21867 didstuff|=did_magic;
21868 break;
21869
21870 case REFILL_ALL:
21871 if(didstuff&did_all) return;
21872
21873 didstuff|=did_all;
21874 }
21875
21876 126 refill_what=type;
21877 126 refill_why=REFILL_FAIRY;
21878 126 StartRefill(type);
21879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
21880 126 else {action=freeze; FFCore.setHeroAction(freeze);}
21881 126 holdclk=0;
21882 126 hopclk=0;
21883 126 }
21884
21885 18882 ++fairyclk;
21886
21887
2/2
✓ Branch 0 taken 8676 times.
✓ Branch 1 taken 10206 times.
18882 if(refilling!=REFILL_FAIRYDONE)
21888 {
21889
2/2
✓ Branch 0 taken 8550 times.
✓ Branch 1 taken 126 times.
8676 if(!refill())
21890 126 refilling=REFILL_FAIRYDONE;
21891 8676 }
21892
21893
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 126 times.
10206 else if(++holdclk>80)
21894 {
21895 126 reset_swordcharge();
21896 126 attackclk=0;
21897 126 action=none; FFCore.setHeroAction(none);
21898 126 fairyclk=0;
21899 126 holdclk=0;
21900 126 refill_why = 0;
21901 126 refilling=REFILL_NONE;
21902 126 map_bkgsfx(true);
21903 126 }
21904 22208 }
21905
21906 702985 int32_t touchcombo(int32_t x,int32_t y)
21907 {
21908
2/2
✓ Branch 0 taken 1405970 times.
✓ Branch 1 taken 702985 times.
2108955 for (int32_t i = 0; i <= 1; ++i)
21909 {
21910
2/2
✓ Branch 0 taken 1137038 times.
✓ Branch 1 taken 268932 times.
1405970 if(tmpscr2[i].valid!=0)
21911 {
21912
2/2
✓ Branch 0 taken 261616 times.
✓ Branch 1 taken 7316 times.
268932 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21913 {
21914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 261616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
261616 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21915 261616 }
21916 else
21917 {
21918
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7316 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
21919 }
21920 268932 }
21921 1405970 }
21922
2/2
✓ Branch 0 taken 701529 times.
✓ Branch 1 taken 1456 times.
702985 if (!_effectflag(x,y,1, -1)) return 0;
21923 701529 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
21924
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 701481 times.
701529 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21925 48 return 0;
21926
3/3
✓ Branch 0 taken 2862 times.
✓ Branch 1 taken 696893 times.
✓ Branch 2 taken 1726 times.
701481 switch(cmb.type)
21927 {
21928 case cBSGRAVE:
21929 case cGRAVE:
21930
3/4
✓ Branch 0 taken 1933 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1933 times.
✗ Branch 3 not taken.
2862 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
21931 {
21932 929 break;
21933 }
21934
21935 [[fallthrough]];
21936 case cARMOS:
21937 {
21938 3659 return cmb.type;
21939 }
21940 }
21941
21942 697822 return 0;
21943 702985 }
21944
21945 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
21946 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
21947
21948 static int32_t GridX(int32_t x)
21949 {
21950 return (x >> 4) << 4;
21951 }
21952
21953 //Snaps 'y' to the combo grid
21954 //Equivalent to calling ComboY(ComboAt(foo,y));
21955 static int32_t GridY(int32_t y)
21956 {
21957 return (y >> 4) << 4;
21958 }
21959
21960 30 int32_t grabComboFromPos(int32_t pos, int32_t type)
21961 {
21962
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 for(int32_t lyr = 6; lyr > -1; --lyr)
21963 {
21964 210 int32_t id = FFCore.tempScreens[lyr]->data[pos];
21965
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 180 times.
210 if(combobuf[id].type == type)
21966 30 return id;
21967 180 }
21968 return -1;
21969 30 }
21970
21971 static int32_t typeMap[176];
21972 static int32_t istrig[176];
21973 static const int32_t SPTYPE_SOLID = -1;
21974 #define SP_VISITED 0x1
21975 #define SPFLAG(dir) (0x2<<dir)
21976 #define BEAM_AGE_LIMIT 32
21977 1234 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
21978 {
21979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = set ? (1 << (set-1)) : ~0;
21980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(spotdir > 3) return; //invalid dir
21981 1234 bool doAge = true;
21982 1234 byte f = 0;
21983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13668 times.
13668 while(unsigned(curpos) < 176)
21984 {
21985 13668 bool block_light = false;
21986 13668 f = SPFLAG(spotdir);
21987
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13341 times.
13668 if((grid[curpos] & f) != f)
21988 {
21989 13341 grid[curpos] |= f;
21990 13341 istrig[curpos] |= trigflag;
21991 13341 doAge = false;
21992 13341 age = 0;
21993 13341 }
21994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 12657 times.
✓ Branch 4 taken 183 times.
13668 switch(spotdir)
21995 {
21996 case up:
21997 176 curpos -= 0x10;
21998 176 break;
21999 case down:
22000 652 curpos += 0x10;
22001 652 break;
22002 case left:
22003
1/2
✓ Branch 0 taken 12657 times.
✗ Branch 1 not taken.
12657 if(!(curpos%0x10))
22004 curpos = -1;
22005 12657 else --curpos;
22006 12657 break;
22007 case right:
22008 183 ++curpos;
22009
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if(!(curpos%0x10))
22010 curpos = -1;
22011 183 break;
22012 }
22013
1/2
✓ Branch 0 taken 13668 times.
✗ Branch 1 not taken.
13668 if(unsigned(curpos) >= 176) break;
22014
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 12440 times.
13668 switch(typeMap[curpos])
22015 {
22016 case SPTYPE_SOLID: case cBLOCKALL:
22017 1228 curpos = -1;
22018 1228 break;
22019 }
22020
3/6
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 13371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13668 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
22021 curpos = -1;
22022
2/2
✓ Branch 0 taken 12440 times.
✓ Branch 1 taken 1228 times.
13668 if(unsigned(curpos) >= 176) break;
22023
22024 12440 f = SPFLAG(oppositeDir[spotdir]);
22025
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if((grid[curpos] & f) != f)
22026 {
22027 12113 grid[curpos] |= f;
22028 12113 istrig[curpos] |= trigflag;
22029 12113 doAge = false;
22030 12113 age = 0;
22031 12113 }
22032
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if(doAge)
22033 {
22034
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 6 times.
327 if(++age > BEAM_AGE_LIMIT)
22035 6 break;
22036 321 }
22037 12113 else doAge = true;
22038
22039
3/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 12137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
12434 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
22040 297 spotdir = dir;
22041
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
12137 else switch(typeMap[curpos])
22042 {
22043 case cLIGHTTARGET:
22044
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
22045 return;
22046 case cMIRROR:
22047 30 spotdir = oppositeDir[spotdir];
22048 30 break;
22049 case cMIRRORSLASH:
22050 switch(spotdir)
22051 {
22052 case up:
22053 spotdir = right; break;
22054 case right:
22055 spotdir = up; break;
22056 case down:
22057 spotdir = left; break;
22058 case left:
22059 spotdir = down; break;
22060 }
22061 break;
22062 case cMIRRORBACKSLASH:
22063 switch(spotdir)
22064 {
22065 case up:
22066 spotdir = left; break;
22067 case left:
22068 spotdir = up; break;
22069 case down:
22070 spotdir = right; break;
22071 case right:
22072 spotdir = down; break;
22073 }
22074 break;
22075 case cMAGICPRISM:
22076 for(byte d = 0; d < 4; ++d)
22077 {
22078 if(d == oppositeDir[spotdir]) continue;
22079 handleBeam(grid, age, d, curpos, set, block, refl);
22080 }
22081 return;
22082 case cMAGICPRISM4:
22083 for(byte d = 0; d < 4; ++d)
22084 {
22085 handleBeam(grid, age, d, curpos, set, block, refl);
22086 }
22087 return;
22088 }
22089 }
22090 1234 }
22091
22092 7262477 void HeroClass::handleSpotlights()
22093 {
22094 typedef byte spot_t;
22095 //Store each different tile/color as grids
22096 7262477 std::map<int32_t, spot_t*> maps;
22097
1/2
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
7262477 int32_t shieldid = getCurrentShield(false);
22098
2/2
✓ Branch 0 taken 6699958 times.
✓ Branch 1 taken 562519 times.
7262477 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
22099
4/4
✓ Branch 0 taken 7252387 times.
✓ Branch 1 taken 10090 times.
✓ Branch 2 taken 562519 times.
✓ Branch 3 taken 6689868 times.
7262477 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
22100
3/6
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7262477 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7262477 times.
✗ Branch 5 not taken.
7262477 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
22101 7262477 memset(istrig, 0, sizeof(istrig));
22102
1/2
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
7262477 clear_bitmap(lightbeam_bmp);
22103
22104
2/2
✓ Branch 0 taken 1278195952 times.
✓ Branch 1 taken 7262477 times.
1285458429 for(size_t pos = 0; pos < 176; ++pos)
22105 {
22106 1278195952 typeMap[pos] = 0;
22107
2/2
✓ Branch 0 taken 1277982476 times.
✓ Branch 1 taken 8947331056 times.
10225313532 for(int32_t lyr = 6; lyr > -1; --lyr)
22108 {
22109 8947331056 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
22110
3/3
✓ Branch 0 taken 209774 times.
✓ Branch 1 taken 8947117580 times.
✓ Branch 2 taken 3702 times.
8947331056 switch(cmb->type)
22111 {
22112 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
22113 case cMAGICPRISM: case cMAGICPRISM4:
22114 case cBLOCKALL: case cLIGHTTARGET:
22115 209774 typeMap[pos] = cmb->type;
22116 209774 break;
22117 case cGLASS:
22118 3702 typeMap[pos] = 0;
22119 3702 break;
22120 default:
22121 {
22122
4/4
✓ Branch 0 taken 3834333772 times.
✓ Branch 1 taken 5112783808 times.
✓ Branch 2 taken 3060942289 times.
✓ Branch 3 taken 773391483 times.
8947117580 if(lyr < 3 && (cmb->walk & 0xF))
22123 {
22124 773391483 typeMap[pos] = SPTYPE_SOLID;
22125 773391483 }
22126 8947117580 continue; //next layer
22127 }
22128 }
22129 213476 break; //hit a combo type
22130 }
22131 1278195952 }
22132
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 7262230 times.
7262477 if(unsigned(heropos) < 176)
22133 {
22134
2/2
✓ Branch 0 taken 676262 times.
✓ Branch 1 taken 6585968 times.
7262230 switch(typeMap[heropos])
22135 {
22136 case SPTYPE_SOLID: case cBLOCKALL:
22137 676262 heropos = -1; //Blocked from hitting player
22138 676262 }
22139 7262230 }
22140
22141
2/2
✓ Branch 0 taken 50837339 times.
✓ Branch 1 taken 7262477 times.
58099816 for(size_t layer = 0; layer < 7; ++layer)
22142 {
22143 50837339 mapscr* curlayer = FFCore.tempScreens[layer];
22144
2/2
✓ Branch 0 taken 8947371664 times.
✓ Branch 1 taken 50837339 times.
8998209003 for(size_t pos = 0; pos < 176; ++pos)
22145 {
22146 //For each spotlight combo on each layer...
22147 8947371664 newcombo const& cmb = combobuf[curlayer->data[pos]];
22148
2/2
✓ Branch 0 taken 8947370430 times.
✓ Branch 1 taken 1234 times.
8947371664 if(cmb.type == cSPOTLIGHT)
22149 {
22150 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
22151
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
2468 int32_t id = (cmb.usrflags&cflag1)
22152
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
22153 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
22154
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(!id) continue;
22155 // zprint2("ID = %ld\n", id);
22156 //Get the grid array for this tile/color
22157 spot_t* grid;
22158
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if(maps[id])
22159 grid = maps[id];
22160 else
22161 {
22162
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 grid = new spot_t[176];
22163 1234 memset(grid, 0, sizeof(spot_t)*176);
22164
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 maps[id] = grid;
22165 }
22166 1234 byte spotdir = cmb.attribytes[0];
22167 1234 int32_t curpos = pos;
22168
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(spotdir > 3)
22169 {
22170 grid[curpos] |= SP_VISITED;
22171 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
22172 }
22173
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1234 times.
✗ Branch 3 not taken.
1234 if(refl && curpos == heropos)
22174 {
22175 spotdir = dir;
22176 }
22177
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
22178 1234 }
22179 8947371664 }
22180 50837339 }
22181
22182 7262477 lightbeam_present = !maps.empty();
22183
22184 //Draw visuals
22185
2/2
✓ Branch 0 taken 7262477 times.
✓ Branch 1 taken 1234 times.
7263711 for(auto it = maps.begin(); it != maps.end();)
22186 {
22187 1234 int32_t id = it->first;
22188 1234 spot_t* grid = it->second;
22189 //
22190 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
22191 1234 int32_t tile = (id&0xFFFFFF);
22192 1234 int32_t cs = (id>>24);
22193 1234 byte c_inner = ((-id)&0x0000FF);
22194 1234 byte c_middle = ((-id)&0x00FF00)>>8;
22195 1234 byte c_outter = ((-id)&0xFF0000)>>16;
22196 //{ Setup color bitmap
22197 1234 BITMAP* cbmp = NULL;
22198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id < 0)
22199 {
22200 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
22201 cbmp = create_bitmap_ex(8, 16*t_max, 16);
22202 clear_bitmap(cbmp);
22203 for(size_t q = 1; q < t_max; ++q)
22204 {
22205 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
22206 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
22207 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
22208 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
22209 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
22210 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
22211 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
22212 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
22213 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
22214 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
22215 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
22216 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
22217 }
22218 //t_gr
22219 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
22220 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
22221 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
22222 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
22223 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
22224 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
22225 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
22226 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
22227 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
22228 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
22229 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
22230 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
22231 //t_up
22232 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
22233 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
22234 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
22235 //t_down
22236 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
22237 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
22238 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
22239 //t_left
22240 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
22241 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
22242 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
22243 //t_right
22244 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
22245 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
22246 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
22247 //t_uleft
22248 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
22249 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
22250 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
22251 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
22252 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
22253 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
22254 //t_uright
22255 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
22256 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
22257 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
22258 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
22259 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
22260 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
22261 //t_dleft
22262 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
22263 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
22264 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
22265 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
22266 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
22267 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
22268 //t_dright
22269 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
22270 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
22271 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
22272 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
22273 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
22274 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
22275 //t_vert
22276 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
22277 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
22278 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
22279 //t_horz
22280 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
22281 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
22282 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
22283 //t_notup
22284 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
22285 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
22286 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
22287 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
22288 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
22289 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
22290 //t_notdown
22291 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
22292 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
22293 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
22294 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
22295 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
22296 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
22297 //t_notleft
22298 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
22299 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
22300 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
22301 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
22302 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
22303 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
22304 //t_notright
22305 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
22306 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
22307 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
22308 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
22309 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
22310 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
22311 //t_all
22312 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
22313 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
22314 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
22315 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
22316 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
22317 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
22318 }
22319 //}
22320 //
22321
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 217184 times.
218418 for(size_t pos = 0; pos < 176; ++pos)
22322 {
22323 217184 int32_t offs = -1;
22324
8/17
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1207 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 511 times.
✓ Branch 7 taken 11477 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 82 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
217184 switch(grid[pos]>>1)
22325 {
22326 203837 case 0: default:
22327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
203837 if(grid[pos])
22328 {
22329 offs = t_gr;
22330 break;
22331 }
22332 203837 continue; //no draw this pos
22333 case 0b0001:
22334 6 offs = t_up;
22335 6 break;
22336 case 0b0010:
22337 offs = t_down;
22338 break;
22339 case 0b0100:
22340 1207 offs = t_left;
22341 1207 break;
22342 case 0b1000:
22343 27 offs = t_right;
22344 27 break;
22345 case 0b0011:
22346 511 offs = t_vert;
22347 511 break;
22348 case 0b1100:
22349 11477 offs = t_horz;
22350 11477 break;
22351 case 0b0101:
22352 offs = t_uleft;
22353 break;
22354 case 0b1001:
22355 37 offs = t_uright;
22356 37 break;
22357 case 0b0110:
22358 offs = t_dleft;
22359 break;
22360 case 0b1010:
22361 82 offs = t_dright;
22362 82 break;
22363 case 0b1110:
22364 offs = t_notup;
22365 break;
22366 case 0b1101:
22367 offs = t_notdown;
22368 break;
22369 case 0b1011:
22370 offs = t_notleft;
22371 break;
22372 case 0b0111:
22373 offs = t_notright;
22374 break;
22375 case 0b1111:
22376 offs = t_all;
22377 break;
22378 }
22379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13347 times.
13347 if(id > 0) //tile
22380 {
22381 //Draw 'tile' at 'pos'
22382
3/6
✓ Branch 0 taken 13347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13347 times.
✗ Branch 5 not taken.
13347 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
22383 13347 }
22384 else //colors
22385 {
22386 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
22387 }
22388 13347 }
22389 //
22390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1234 if(cbmp) destroy_bitmap(cbmp);
22391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] it->second;
22392
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 it = maps.erase(it);
22393 }
22394 //Check triggers
22395 7262477 bool hastrigs = false, istrigged = true;
22396
1/2
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
7262477 bool alltrig = getmapflag(mLIGHTBEAM);
22397
2/2
✓ Branch 0 taken 50837339 times.
✓ Branch 1 taken 7262477 times.
58099816 for(size_t layer = 0; layer < 7; ++layer)
22398 {
22399 50837339 mapscr* curlayer = FFCore.tempScreens[layer];
22400
2/2
✓ Branch 0 taken 8947371664 times.
✓ Branch 1 taken 50837339 times.
8998209003 for(size_t pos = 0; pos < 176; ++pos)
22401 {
22402 8947371664 newcombo const* cmb = &combobuf[curlayer->data[pos]];
22403
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 8947370430 times.
8947371664 if(cmb->type == cLIGHTTARGET)
22404 {
22405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22406 1234 hastrigs = true;
22407 1234 bool trigged = (istrig[pos]&trigflag);
22408
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22409 trigged = !trigged;
22410
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22411 {
22412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22413 {
22414 curlayer->data[pos] -= 1;
22415 istrigged = false;
22416 }
22417 249 }
22418 else //Unsolved version
22419 {
22420
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22421 1 curlayer->data[pos] += 1;
22422 984 else istrigged = false;
22423 }
22424 1234 }
22425
2/2
✓ Branch 0 taken 8947366728 times.
✓ Branch 1 taken 3702 times.
8947370430 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22426 {
22427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22428 3702 bool trigged = (istrig[pos]&trigflag);
22429
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22430 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22431 {
22432
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 do_trigger_combo(layer, pos);
22433 6 }
22434 3702 }
22435 8947371664 }
22436 50837339 }
22437
1/2
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
7262477 word c = tmpscr->numFFC();
22438
2/2
✓ Branch 0 taken 7262477 times.
✓ Branch 1 taken 228080551 times.
235343028 for(word i=0; i<c; i++)
22439 {
22440 228080551 ffcdata& ffc = tmpscr->ffcs[i];
22441
1/2
✓ Branch 0 taken 228080551 times.
✗ Branch 1 not taken.
228080551 newcombo const* cmb = &combobuf[ffc.getData()];
22442
7/14
✓ Branch 0 taken 228080551 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 228080551 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228080551 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 228080551 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 228080551 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 228080551 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 228080551 times.
✗ Branch 13 not taken.
228080551 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
22443
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 228079317 times.
228080551 if(cmb->type == cLIGHTTARGET)
22444 {
22445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
22446 1234 hastrigs = true;
22447 1234 bool trigged = (istrig[pos]&trigflag);
22448
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
22449 trigged = !trigged;
22450
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 249 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
22451 {
22452
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
22453 {
22454 ffc.incData(-1);
22455 istrigged = false;
22456 }
22457 249 }
22458 else //Unsolved version
22459 {
22460
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
22461
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ffc.incData(1);
22462 984 else istrigged = false;
22463 }
22464 1234 }
22465
2/2
✓ Branch 0 taken 228076849 times.
✓ Branch 1 taken 2468 times.
228079317 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
22466 {
22467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
22468 2468 bool trigged = (istrig[pos]&trigflag);
22469
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
22470 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
22471 {
22472
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 do_trigger_combo_ffc(i);
22473 4 }
22474 2468 }
22475 228080551 }
22476
6/6
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 7261243 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 249 times.
7262477 if(hastrigs && istrigged && !alltrig)
22477 {
22478
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 hidden_entrance(0,true,false,-7);
22479
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sfx(tmpscr->secretsfx);
22480
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(tmpscr->flags5&fTEMPSECRETS))
22481 {
22482
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mSECRET);
22483
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mLIGHTBEAM);
22484 1 }
22485 1 }
22486 7262477 }
22487
22488 7252157 void HeroClass::checktouchblk()
22489 {
22490
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 7237802 times.
7252157 if(toogam) return;
22491
22492
2/2
✓ Branch 0 taken 482414 times.
✓ Branch 1 taken 6755388 times.
7237802 if(!pushing)
22493 6755388 return;
22494
22495 482414 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
22496
22497
4/4
✓ Branch 0 taken 482234 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 482138 times.
482414 if(charging > 0 || spins > 0) //if not I probably will at some point...
22498 {
22499
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
22500
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
22501
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
22502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
22503 else
22504 {
22505
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
22506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
22507
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
22508 else if(Right())tdir=3;
22509 }
22510 276 }
22511
22512 482414 int32_t tx=0,ty=-1;
22513
22514
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 119245 times.
✓ Branch 2 taken 102905 times.
✓ Branch 3 taken 124250 times.
✓ Branch 4 taken 136014 times.
482414 switch(tdir)
22515 {
22516 case up:
22517
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 119137 times.
119245 if(touchcombo(x,y+(bigHitbox?0:7)))
22518 {
22519 108 tx=x;
22520 108 ty=y+(bigHitbox?0:7);
22521 108 }
22522
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 119116 times.
119137 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
22523 {
22524 21 tx=x+8;
22525 21 ty=y+(bigHitbox?0:7);
22526 21 }
22527
22528 119245 break;
22529
22530 case down:
22531
2/2
✓ Branch 0 taken 1471 times.
✓ Branch 1 taken 101434 times.
102905 if(touchcombo(x,y+16))
22532 {
22533 1471 tx=x;
22534 1471 ty=y+16;
22535 1471 }
22536
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 101177 times.
101434 else if(touchcombo(x+8,y+16))
22537 {
22538 257 tx=x+8;
22539 257 ty=y+16;
22540 257 }
22541
22542 102905 break;
22543
22544 case left:
22545
2/2
✓ Branch 0 taken 123539 times.
✓ Branch 1 taken 711 times.
124250 if(touchcombo(x-1,y+15))
22546 {
22547 711 tx=x-1;
22548 711 ty=y+15;
22549 711 }
22550
22551 124250 break;
22552
22553 case right:
22554
2/2
✓ Branch 0 taken 134923 times.
✓ Branch 1 taken 1091 times.
136014 if(touchcombo(x+16,y+15))
22555 {
22556 1091 tx=x+16;
22557 1091 ty=y+15;
22558 1091 }
22559
22560 136014 break;
22561 }
22562
22563
2/2
✓ Branch 0 taken 478755 times.
✓ Branch 1 taken 3659 times.
482414 if(ty>=0)
22564 {
22565 3659 ty&=0xF0;
22566 3659 tx&=0xF0;
22567 3659 int32_t di = ty+(tx>>4);
22568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3659 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3659 if((getAction() != hopping || isSideViewHero()))
22569 {
22570 3659 trigger_armos_grave(0, di, dir);
22571 3659 }
22572 3659 }
22573 7252157 }
22574
22575 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
22576 {
22577 switch(cdir)
22578 {
22579 case up:
22580 cy-=16;
22581 break;
22582
22583 case down:
22584 cy+=16;
22585 break;
22586
22587 case left:
22588 cx-=16;
22589 break;
22590
22591 case right:
22592 cx+=16;
22593 break;
22594 }
22595
22596 // off the screen
22597 if(cx<0 || cy<0 || cx>255 || cy>175)
22598 {
22599 int32_t ns = nextscr(cdir);
22600
22601 if(ns==0xFFFF) return 0;
22602
22603 // want actual screen index, not game->maps[] index
22604 ns = (ns&127) + (ns>>7)*MAPSCRS;
22605
22606 switch(cdir)
22607 {
22608 case up:
22609 cy=160;
22610 break;
22611
22612 case down:
22613 cy=0;
22614 break;
22615
22616 case left:
22617 cx=240;
22618 break;
22619
22620 case right:
22621 cx=0;
22622 break;
22623 }
22624
22625 // from MAPCOMBO()
22626 int32_t cmb = (cy&0xF0)+(cx>>4);
22627
22628 if(cmb>175)
22629 return 0;
22630
22631 return TheMaps[ns].data[cmb]; // entire combo code
22632 }
22633
22634 return MAPCOMBO(cx,cy);
22635 }
22636
22637 8960 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
22638 {
22639
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 2194 times.
✓ Branch 3 taken 2580 times.
✓ Branch 4 taken 2361 times.
8960 switch(cdir)
22640 {
22641 case up:
22642 1825 cy-=16;
22643 1825 break;
22644
22645 case down:
22646 2194 cy+=16;
22647 2194 break;
22648
22649 case left:
22650 2580 cx-=16;
22651 2580 break;
22652
22653 case right:
22654 2361 cx+=16;
22655 2361 break;
22656 }
22657
22658 // off the screen
22659
8/8
✓ Branch 0 taken 8907 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 8838 times.
✓ Branch 3 taken 69 times.
✓ Branch 4 taken 8725 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 121 times.
✓ Branch 7 taken 8604 times.
8960 if(cx<0 || cy<0 || cx>255 || cy>175)
22660 {
22661 356 int32_t ns = nextscr(cdir);
22662
22663
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 352 times.
356 if(ns==0xFFFF) return 0;
22664
22665 // want actual screen index, not game->maps[] index
22666 352 ns = (ns&127) + (ns>>7)*MAPSCRS;
22667
22668
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 119 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 113 times.
352 switch(cdir)
22669 {
22670 case up:
22671 67 cy=160;
22672 67 break;
22673
22674 case down:
22675 119 cy=0;
22676 119 break;
22677
22678 case left:
22679 53 cx=240;
22680 53 break;
22681
22682 case right:
22683 113 cx=0;
22684 113 break;
22685 }
22686
22687 // from MAPCOMBO()
22688 352 int32_t cmb = (cy&0xF0)+(cx>>4);
22689
22690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 if(cmb>175)
22691 return 0;
22692
22693
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 281 times.
352 if(!comboflag)
22694 {
22695 281 return TheMaps[ns].sflag[cmb]; // flag
22696 }
22697 else
22698 {
22699 71 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
22700 }
22701 }
22702
22703
2/2
✓ Branch 0 taken 2068 times.
✓ Branch 1 taken 6536 times.
8604 if(comboflag)
22704 {
22705 2068 return MAPCOMBOFLAG(cx,cy);
22706 }
22707
22708 6536 return MAPFLAG(cx,cy);
22709 8960 }
22710
22711 bool did_secret;
22712
22713 7252157 void HeroClass::checkspecial()
22714 {
22715 7252157 checktouchblk();
22716
22717 7252157 bool hasmainguy = hasMainGuy(); // calculate it once
22718
22719
4/4
✓ Branch 0 taken 7179558 times.
✓ Branch 1 taken 72599 times.
✓ Branch 2 taken 4660495 times.
✓ Branch 3 taken 2519063 times.
7252157 if(!(loaded_enemies && !hasmainguy))
22720 4733094 did_secret=false;
22721 else
22722 {
22723 // after beating enemies
22724
22725 // generic 'Enemies->' trigger
22726
2/2
✓ Branch 0 taken 17633441 times.
✓ Branch 1 taken 2519063 times.
20152504 for(auto lyr = 0; lyr < 7; ++lyr)
22727 {
22728
2/2
✓ Branch 0 taken 3103485616 times.
✓ Branch 1 taken 17633441 times.
3121119057 for(auto pos = 0; pos < 176; ++pos)
22729 {
22730 3103485616 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
22731
2/2
✓ Branch 0 taken 3103485613 times.
✓ Branch 1 taken 3 times.
3103485616 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22732 {
22733 3 do_trigger_combo(lyr,pos);
22734 3 }
22735 3103485616 }
22736 17633441 }
22737 2519063 word c = tmpscr->numFFC();
22738
2/2
✓ Branch 0 taken 77373130 times.
✓ Branch 1 taken 2519063 times.
79892193 for(word i=0; i<c; i++)
22739 {
22740 77373130 ffcdata& ffc = tmpscr->ffcs[i];
22741 77373130 newcombo const& cmb = combobuf[ffc.getData()];
22742
1/2
✓ Branch 0 taken 77373130 times.
✗ Branch 1 not taken.
77373130 if(cmb.triggerflags[2] & combotriggerENEMIESKILLED)
22743 {
22744 do_trigger_combo_ffc(i);
22745 }
22746 77373130 }
22747
1/2
✓ Branch 0 taken 2519063 times.
✗ Branch 1 not taken.
2519063 if(tmpscr->flags9 & fENEMY_WAVES)
22748 {
22749 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
22750 }
22751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2519063 times.
2519063 if(!hasmainguy)
22752 {
22753 // item
22754
2/2
✓ Branch 0 taken 2518594 times.
✓ Branch 1 taken 469 times.
2519063 if(hasitem&(4|2|1))
22755 {
22756 469 int32_t Item=tmpscr->item;
22757
22758 //if(getmapflag())
22759 // Item=0;
22760
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 469 times.
469 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22761 {
22762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if(hasitem==1)
22763 469 sfx(WAV_CLEARED);
22764
22765
2/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
938 items.add(new item((zfix)tmpscr->itemx,
22766
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 469 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 469 times.
✗ Branch 11 not taken.
469 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22767
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 443 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 443 times.
✗ Branch 9 not taken.
469 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22769 469 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22770 469 }
22771
22772 469 hasitem &= ~ (4|2|1);
22773 469 }
22774 // if room has traps, guys don't come back
22775
2/2
✓ Branch 0 taken 1289760256 times.
✓ Branch 1 taken 2519063 times.
1292279319 for(int32_t i=0; i<eMAXGUYS; i++)
22776 {
22777
4/4
✓ Branch 0 taken 37526743 times.
✓ Branch 1 taken 1252233513 times.
✓ Branch 2 taken 32545823 times.
✓ Branch 3 taken 4980920 times.
1289760256 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
22778
4/4
✓ Branch 0 taken 22637 times.
✓ Branch 1 taken 4958283 times.
✓ Branch 2 taken 22611 times.
✓ Branch 3 taken 26 times.
4980946 if(guys.idCount(i) && !getmapflag(mTMPNORET))
22779 26 setmapflag(mTMPNORET);
22780 1289760256 }
22781 // clear enemies and open secret
22782
4/4
✓ Branch 0 taken 2394712 times.
✓ Branch 1 taken 124351 times.
✓ Branch 2 taken 2394197 times.
✓ Branch 3 taken 515 times.
2519063 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
22783 {
22784 515 bool only16_31 = get_qr(qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
22785 515 hidden_entrance(0,true,only16_31,-2);
22786
22787
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 26 times.
515 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
22788 {
22789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
22790 26 }
22791
22792 515 sfx(tmpscr->secretsfx);
22793 515 did_secret=true;
22794 515 }
22795 2519063 }
22796 }
22797
22798 // doors
22799 7252157 bool has_shutter = false;
22800
2/2
✓ Branch 0 taken 5823521 times.
✓ Branch 1 taken 26392213 times.
32215734 for(int32_t i=0; i<4; i++)
22801
2/2
✓ Branch 0 taken 24963577 times.
✓ Branch 1 taken 1428636 times.
26392213 if(tmpscr->door[i]==dSHUTTER)
22802 {
22803 1428636 has_shutter = true;
22804
4/4
✓ Branch 0 taken 1401029 times.
✓ Branch 1 taken 27607 times.
✓ Branch 2 taken 918 times.
✓ Branch 3 taken 1400111 times.
1428636 if(opendoors==0 && loaded_enemies)
22805 {
22806
4/4
✓ Branch 0 taken 1160411 times.
✓ Branch 1 taken 239700 times.
✓ Branch 2 taken 1158774 times.
✓ Branch 3 taken 1637 times.
1400111 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22807 1637 opendoors=12;
22808 1400111 }
22809
2/2
✓ Branch 0 taken 22582 times.
✓ Branch 1 taken 5943 times.
28525 else if(opendoors<0)
22810 5943 ++opendoors;
22811
2/2
✓ Branch 0 taken 20692 times.
✓ Branch 1 taken 1890 times.
22582 else if((--opendoors)==0)
22812 1890 openshutters();
22813
22814 1428636 break;
22815 }
22816
10/10
✓ Branch 0 taken 5823521 times.
✓ Branch 1 taken 1428636 times.
✓ Branch 2 taken 5706108 times.
✓ Branch 3 taken 117413 times.
✓ Branch 4 taken 5638258 times.
✓ Branch 5 taken 67850 times.
✓ Branch 6 taken 5576274 times.
✓ Branch 7 taken 61984 times.
✓ Branch 8 taken 3258922 times.
✓ Branch 9 taken 2317352 times.
7252157 if(!has_shutter && !opendoors && loaded_enemies && !(tmpscr->flags&fSHUTTERS) && !hasmainguy)
22817 {
22818 2317352 openshutters();
22819 2317352 }
22820
22821 // set boss flag when boss is gone
22822
6/6
✓ Branch 0 taken 7179558 times.
✓ Branch 1 taken 72599 times.
✓ Branch 2 taken 133347 times.
✓ Branch 3 taken 7046211 times.
✓ Branch 4 taken 99762 times.
✓ Branch 5 taken 33585 times.
7252157 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
22823 {
22824 33585 game->lvlitems[dlevel]|=liBOSS;
22825 33585 stop_sfx(tmpscr->bosssfx);
22826 33585 }
22827
22828
2/2
✓ Branch 0 taken 7237140 times.
✓ Branch 1 taken 15017 times.
7252157 if(getmapflag(mCHEST)) // if special stuff done before
22829 {
22830 15017 remove_chests((currscr>=128)?1:0);
22831 15017 }
22832
22833
1/2
✓ Branch 0 taken 7252157 times.
✗ Branch 1 not taken.
7252157 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
22834 {
22835 remove_lockedchests((currscr>=128)?1:0);
22836 }
22837
22838
2/2
✓ Branch 0 taken 7226398 times.
✓ Branch 1 taken 25759 times.
7252157 if(getmapflag(mBOSSCHEST)) // if special stuff done before
22839 {
22840 25759 remove_bosschests((currscr>=128)?1:0);
22841 25759 }
22842
22843 7252157 clear_xstatecombos((currscr>=128)?1:0);
22844
22845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7252157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7252157 if((hasitem&8) && triggered_screen_secrets)
22846 {
22847 int32_t Item=tmpscr->item;
22848
22849 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
22850 {
22851 items.add(new item((zfix)tmpscr->itemx,
22852 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
22853 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
22854 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
22855 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
22856 }
22857
22858 hasitem &= ~8;
22859 }
22860 7252157 }
22861
22862 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
22863 5074008 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
22864 {
22865 int32_t tmp;
22866 5074008 poses[0] = COMBOPOS(x1,y1);
22867
22868 5074008 tmp = COMBOPOS(x1,y2);
22869
2/2
✓ Branch 0 taken 3906352 times.
✓ Branch 1 taken 1167656 times.
5074008 if(tmp == poses[0])
22870 3906352 poses[1] = -1;
22871 1167656 else poses[1] = tmp;
22872
22873 5074008 tmp = COMBOPOS(x2,y1);
22874
3/4
✓ Branch 0 taken 2251233 times.
✓ Branch 1 taken 2822775 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2251233 times.
5074008 if(tmp == poses[0] || tmp == poses[1])
22875 2822775 poses[2] = -1;
22876 2251233 else poses[2] = tmp;
22877
22878 5074008 tmp = COMBOPOS(x2,y2);
22879
6/6
✓ Branch 0 taken 2903301 times.
✓ Branch 1 taken 2170707 times.
✓ Branch 2 taken 2251233 times.
✓ Branch 3 taken 652068 times.
✓ Branch 4 taken 1735645 times.
✓ Branch 5 taken 515588 times.
5074008 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
22880 4558420 poses[3] = -1;
22881 515588 else poses[3] = tmp;
22882 5074008 }
22883
22884 7247591 void HeroClass::checkspecial2(int32_t *ls)
22885 {
22886
6/8
✓ Branch 0 taken 6589666 times.
✓ Branch 1 taken 657925 times.
✓ Branch 2 taken 6333732 times.
✓ Branch 3 taken 255934 times.
✓ Branch 4 taken 6333732 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6333732 times.
7247591 if(get_qr(qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
22887 {
22888 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
22889
2/2
✓ Branch 0 taken 18156 times.
✓ Branch 1 taken 6315576 times.
6333732 if (!fairyclk)
22890 {
22891
2/2
✓ Branch 0 taken 1882217 times.
✓ Branch 1 taken 4433359 times.
6315576 if(y.getInt()&7)
22892 1882217 return;
22893
22894
2/2
✓ Branch 0 taken 2446500 times.
✓ Branch 1 taken 1986859 times.
4433359 if(x.getInt()&7)
22895 2446500 return;
22896 1986859 }
22897 2005015 }
22898
22899
2/2
✓ Branch 0 taken 5461 times.
✓ Branch 1 taken 2913413 times.
2918874 if(toogam) return;
22900
22901 2913413 bool didstrig = false;
22902
22903
2/2
✓ Branch 0 taken 5826491 times.
✓ Branch 1 taken 2913410 times.
8739901 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
22904 {
22905
4/4
✓ Branch 0 taken 11652982 times.
✓ Branch 1 taken 5826488 times.
✓ Branch 2 taken 23305961 times.
✓ Branch 3 taken 11652979 times.
40785428 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
22906 {
22907
2/2
✓ Branch 0 taken 11652979 times.
✓ Branch 1 taken 11652982 times.
23305961 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
22908 23305961 int32_t stype = cmb.type;
22909 23305961 int32_t warpsound = cmb.attribytes[0];
22910
2/2
✓ Branch 0 taken 23305759 times.
✓ Branch 1 taken 202 times.
23305961 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
22911 202 stype = cNONE;
22912
2/2
✓ Branch 0 taken 23305958 times.
✓ Branch 1 taken 3 times.
23305961 if(stype==cSWARPA)
22913 {
22914
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
22915 {
22916 didpit=true;
22917 pitx=x;
22918 pity=y;
22919 }
22920
22921 3 sdir=dir;
22922 3 dowarp(0,0,warpsound);
22923 3 return;
22924 }
22925
22926
1/2
✓ Branch 0 taken 23305958 times.
✗ Branch 1 not taken.
23305958 if(stype==cSWARPB)
22927 {
22928 if(tmpscr->flags5&fDIRECTSWARP)
22929 {
22930 didpit=true;
22931 pitx=x;
22932 pity=y;
22933 }
22934
22935 sdir=dir;
22936 dowarp(0,1,warpsound);
22937 return;
22938 }
22939
22940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23305958 times.
23305958 if(stype==cSWARPC)
22941 {
22942 if(tmpscr->flags5&fDIRECTSWARP)
22943 {
22944 didpit=true;
22945 pitx=x;
22946 pity=y;
22947 }
22948
22949 sdir=dir;
22950 dowarp(0,2,warpsound);
22951 return;
22952 }
22953
22954
1/2
✓ Branch 0 taken 23305958 times.
✗ Branch 1 not taken.
23305958 if(stype==cSWARPD)
22955 {
22956 if(tmpscr->flags5&fDIRECTSWARP)
22957 {
22958 didpit=true;
22959 pitx=x;
22960 pity=y;
22961 }
22962
22963 sdir=dir;
22964 dowarp(0,3,warpsound);
22965 return;
22966 }
22967
22968
1/2
✓ Branch 0 taken 23305958 times.
✗ Branch 1 not taken.
23305958 if(stype==cSWARPR)
22969 {
22970 if(tmpscr->flags5&fDIRECTSWARP)
22971 {
22972 didpit=true;
22973 pitx=x;
22974 pity=y;
22975 }
22976
22977 sdir=dir;
22978 dowarp(0,(zc_oldrand()%4),warpsound);
22979 return;
22980 }
22981
22982 23305958 int32_t pos = COMBOPOS(x+j, y+i);
22983
4/4
✓ Branch 0 taken 23303802 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 23305248 times.
✓ Branch 3 taken 710 times.
23305958 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
22984 {
22985 // zprint("Step Secs\n");
22986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
22987 {
22988 if(!didstrig)
22989 {
22990 stepsecret = pos;
22991
22992 if(!(tmpscr->flags5&fTEMPSECRETS))
22993 {
22994 setmapflag(mSECRET);
22995 }
22996 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
22997 //zprint("Step Secrets SFX: %d\n", thesfx);
22998 sfx(warpsound,pan((int32_t)x));
22999 hidden_entrance(0,true,false);
23000 didstrig = true;
23001 }
23002 }
23003 else
23004 {
23005
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
23006 {
23007 345 stepsecret = pos;
23008 345 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
23009 345 hidden_entrance(0,true,only16_31);
23010 345 didstrig = true;
23011 //play trigger sound
23012 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
23013 //zprint("Step Secrets SFX: %d\n", thesfx);
23014 //sfx(thesfx,pan((int32_t)x));
23015 345 sfx(warpsound,pan((int32_t)x));
23016 345 }
23017 }
23018 710 }
23019 34958937 }
23020 5826488 }
23021
23022 2913410 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
23023
23024 // check if he's standing on a warp he just came out of
23025 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
23026
2/2
✓ Branch 0 taken 1082887 times.
✓ Branch 1 taken 1830523 times.
2913410 if (!get_qr(qr_210_WARPRETURN))
23027 {
23028
6/6
✓ Branch 0 taken 1829012 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 195680 times.
✓ Branch 3 taken 1633332 times.
✓ Branch 4 taken 16408 times.
✓ Branch 5 taken 179272 times.
1830523 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
23029 {
23030
5/6
✓ Branch 0 taken 178639 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 177634 times.
✓ Branch 3 taken 1005 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 177634 times.
179272 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
23031 {
23032
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 177629 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
177634 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
23033 177634 else return;
23034 }
23035 1638 }
23036 1652889 }
23037 else
23038 {
23039
2/2
✓ Branch 0 taken 901169 times.
✓ Branch 1 taken 181718 times.
1082887 if((int(y)&0xF8)==warpy)
23040 {
23041
2/2
✓ Branch 0 taken 1567 times.
✓ Branch 1 taken 180151 times.
181718 if(x==warpx)
23042 {
23043
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180151 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
180151 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
23044 180151 else return;
23045 }
23046 1567 }
23047 }
23048
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 2555459 times.
2555625 if (!RaftPass) warpy=-1;
23049
23050
6/6
✓ Branch 0 taken 2551824 times.
✓ Branch 1 taken 3469 times.
✓ Branch 2 taken 164076 times.
✓ Branch 3 taken 2387748 times.
✓ Branch 4 taken 121865 times.
✓ Branch 5 taken 42211 times.
2555625 if(((int32_t)y<raftwarpy-(get_qr(qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_qr(qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
23051 {
23052 2433428 raftwarpy = -1;
23053 2433428 }
23054
6/6
✓ Branch 0 taken 2552620 times.
✓ Branch 1 taken 2673 times.
✓ Branch 2 taken 145599 times.
✓ Branch 3 taken 2407021 times.
✓ Branch 4 taken 106397 times.
✓ Branch 5 taken 39202 times.
2555293 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
23055 {
23056 2448896 raftwarpx = -1;
23057 2448896 }
23058 2555293 int32_t tx=x;
23059 2555293 int32_t ty=y;
23060
23061 2555293 int32_t flag=0;
23062 2555293 int32_t flag2=0;
23063 2555293 int32_t flag3=0;
23064 2555293 int32_t type=0;
23065 2555293 int32_t water=0;
23066 2555293 int32_t index = 0;
23067
23068 2555293 bool setsave=false;
23069 2555293 int32_t warpsfx2 = 0;
23070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2555293 times.
2555293 if (RaftPass) goto RaftingStuff;
23071
23072 //bool gotpit=false;
23073
23074 int32_t x1,x2,y1,y2;
23075 2555293 x1 = tx;
23076 2555293 x2 = tx+15;
23077 2555293 y1 = ty;
23078 2555293 y2 = ty+15;
23079
23080
5/6
✓ Branch 0 taken 1694735 times.
✓ Branch 1 taken 860558 times.
✓ Branch 2 taken 1694735 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✓ Branch 5 taken 1694901 times.
2555293 if((diagonalMovement||NO_GRIDLOCK))
23081 {
23082 860724 x1 = tx+4;
23083 860724 x2 = tx+11;
23084 860724 y1 = ty+4;
23085 860724 y2 = ty+11;
23086 860724 }
23087
23088 int32_t types[4];
23089 2555625 types[0]=types[1]=types[2]=types[3]=-1;
23090 int32_t cids[4];
23091 int32_t ffcids[4];
23092 2555625 cids[0]=cids[1]=cids[2]=cids[3]=-1;
23093 2555625 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
23094 //
23095 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
23096 //
23097 2555625 types[0] = MAPFLAG(x1,y1);
23098 2555625 types[1] = MAPFLAG(x1,y2);
23099 2555625 types[2] = MAPFLAG(x2,y1);
23100 2555625 types[3] = MAPFLAG(x2,y2);
23101
23102
23103 //MAPFFCOMBO
23104
23105
23106
6/6
✓ Branch 0 taken 2498174 times.
✓ Branch 1 taken 57451 times.
✓ Branch 2 taken 2491529 times.
✓ Branch 3 taken 6645 times.
✓ Branch 4 taken 28244 times.
✓ Branch 5 taken 2463285 times.
2555625 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23107 2463285 flag = types[0];
23108 // 2.10 compatibility...
23109
8/10
✓ Branch 0 taken 57010 times.
✓ Branch 1 taken 35330 times.
✓ Branch 2 taken 47958 times.
✓ Branch 3 taken 9052 times.
✓ Branch 4 taken 35869 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 35869 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 35869 times.
92340 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
23110 12089 flag = types[0];
23111
23112
23113 2555625 types[0] = MAPCOMBOFLAG(x1,y1);
23114 2555625 types[1] = MAPCOMBOFLAG(x1,y2);
23115 2555625 types[2] = MAPCOMBOFLAG(x2,y1);
23116 2555625 types[3] = MAPCOMBOFLAG(x2,y2);
23117
23118
6/6
✓ Branch 0 taken 2553184 times.
✓ Branch 1 taken 2441 times.
✓ Branch 2 taken 2552731 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 1092 times.
✓ Branch 5 taken 2551639 times.
2555625 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23119 2551639 flag2 = types[0];
23120
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 3986 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3986 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
23121 flag2 = types[0];
23122
23123 2555625 types[0] = MAPFFCOMBOFLAG(x1,y1);
23124 2555625 types[1] = MAPFFCOMBOFLAG(x1,y2);
23125 2555625 types[2] = MAPFFCOMBOFLAG(x2,y1);
23126 2555625 types[3] = MAPFFCOMBOFLAG(x2,y2);
23127
23128
23129 //
23130
23131
6/6
✓ Branch 0 taken 2555441 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 2555434 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 2555429 times.
2555625 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23132 2555429 flag3 = types[0];
23133
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
196 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
23134 flag3 = types[0];
23135
23136 //
23137 // Now, let's check for warp combos...
23138 //
23139
23140 //
23141
23142 2555625 cids[0] = MAPCOMBO(x1,y1);
23143 2555625 cids[1] = MAPCOMBO(x1,y2);
23144 2555625 cids[2] = MAPCOMBO(x2,y1);
23145 2555625 cids[3] = MAPCOMBO(x2,y2);
23146
23147 2555625 types[0] = COMBOTYPE(x1,y1);
23148
23149
2/2
✓ Branch 0 taken 2519487 times.
✓ Branch 1 taken 36138 times.
2555625 if(MAPFFCOMBO(x1,y1))
23150 {
23151 36138 types[0] = FFCOMBOTYPE(x1,y1);
23152 36138 cids[0] = MAPFFCOMBO(x1,y1);
23153 36138 }
23154
23155 2555625 types[1] = COMBOTYPE(x1,y2);
23156
23157
2/2
✓ Branch 0 taken 2524619 times.
✓ Branch 1 taken 31006 times.
2555625 if(MAPFFCOMBO(x1,y2))
23158 {
23159 31006 types[1] = FFCOMBOTYPE(x1,y2);
23160 31006 cids[1] = MAPFFCOMBO(x1,y2);
23161 31006 }
23162
23163 2555625 types[2] = COMBOTYPE(x2,y1);
23164
23165
2/2
✓ Branch 0 taken 2519420 times.
✓ Branch 1 taken 36205 times.
2555625 if(MAPFFCOMBO(x2,y1))
23166 {
23167 36205 types[2] = FFCOMBOTYPE(x2,y1);
23168 36205 cids[2] = MAPFFCOMBO(x2,y1);
23169 36205 }
23170 2555625 types[3] = COMBOTYPE(x2,y2);
23171
23172
2/2
✓ Branch 0 taken 2524503 times.
✓ Branch 1 taken 31122 times.
2555625 if(MAPFFCOMBO(x2,y2))
23173 {
23174 31122 types[3] = FFCOMBOTYPE(x2,y2);
23175 31122 cids[3] = MAPFFCOMBO(x2,y2);
23176 31122 }
23177 // Change B, C and D warps into A, for the comparison below...
23178
2/2
✓ Branch 0 taken 10221836 times.
✓ Branch 1 taken 2555625 times.
12777461 for(int32_t i=0; i<4; i++)
23179 {
23180
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 10221512 times.
10221836 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23181 {
23182 324 types[i] = cNONE;
23183 324 continue;
23184 }
23185
2/2
✓ Branch 0 taken 2489 times.
✓ Branch 1 taken 10219023 times.
10221512 if(types[i]==cCAVE)
23186 {
23187 2489 index=0;
23188 2489 warpsfx2 = combobuf[cids[i]].attribytes[0];
23189 2489 }
23190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10219023 times.
10219023 else if(types[i]==cCAVEB)
23191 {
23192 types[i]=cCAVE;
23193 index=1;
23194 warpsfx2 = combobuf[cids[i]].attribytes[0];
23195 }
23196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10219023 times.
10219023 else if(types[i]==cCAVEC)
23197 {
23198 types[i]=cCAVE;
23199 index=2;
23200 warpsfx2 = combobuf[cids[i]].attribytes[0];
23201 }
23202
1/2
✓ Branch 0 taken 10219023 times.
✗ Branch 1 not taken.
10219023 else if(types[i]==cCAVED)
23203 {
23204 types[i]=cCAVE;
23205 index=3;
23206 warpsfx2 = combobuf[cids[i]].attribytes[0];
23207 }
23208
23209
2/2
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 10220028 times.
10221512 if(types[i]==cPIT)
23210 {
23211 1484 index=0;
23212 1484 warpsfx2 = combobuf[cids[i]].attribytes[0];
23213 1484 }
23214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220028 times.
10220028 else if(types[i]==cPITB)
23215 {
23216 types[i]=cPIT;
23217 warpsfx2 = combobuf[cids[i]].attribytes[0];
23218 index=1;
23219 }
23220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220028 times.
10220028 else if(types[i]==cPITC)
23221 {
23222 types[i]=cPIT;
23223 warpsfx2 = combobuf[cids[i]].attribytes[0];
23224 index=2;
23225 }
23226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220028 times.
10220028 else if(types[i]==cPITD)
23227 {
23228 types[i]=cPIT;
23229 warpsfx2 = combobuf[cids[i]].attribytes[0];
23230 index=3;
23231 }
23232
1/2
✓ Branch 0 taken 10220028 times.
✗ Branch 1 not taken.
10220028 else if(types[i]==cPITR)
23233 {
23234 types[i]=cPIT;
23235 warpsfx2 = combobuf[cids[i]].attribytes[0];
23236 index=zc_oldrand()%4;
23237 }
23238
23239
2/2
✓ Branch 0 taken 12200 times.
✓ Branch 1 taken 10209312 times.
10221512 if(types[i]==cSTAIR)
23240 {
23241 12200 index=0;
23242 12200 warpsfx2 = combobuf[cids[i]].attribytes[0];
23243 12200 }
23244
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 10209184 times.
10209312 else if(types[i]==cSTAIRB)
23245 {
23246 128 types[i]=cSTAIR;
23247 128 warpsfx2 = combobuf[cids[i]].attribytes[0];
23248 128 index=1;
23249 128 }
23250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10209184 times.
10209184 else if(types[i]==cSTAIRC)
23251 {
23252 types[i]=cSTAIR;
23253 warpsfx2 = combobuf[cids[i]].attribytes[0];
23254 index=2;
23255 }
23256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10209184 times.
10209184 else if(types[i]==cSTAIRD)
23257 {
23258 types[i]=cSTAIR;
23259 warpsfx2 = combobuf[cids[i]].attribytes[0];
23260 index=3;
23261 }
23262
1/2
✓ Branch 0 taken 10209184 times.
✗ Branch 1 not taken.
10209184 else if(types[i]==cSTAIRR)
23263 {
23264 types[i]=cSTAIR;
23265 index=zc_oldrand()%4;
23266 warpsfx2 = combobuf[cids[i]].attribytes[0];
23267 }
23268
23269
2/2
✓ Branch 0 taken 2136 times.
✓ Branch 1 taken 10219376 times.
10221512 if(types[i]==cCAVE2)
23270 {
23271 2136 index=0;
23272 2136 warpsfx2 = combobuf[cids[i]].attribytes[0];
23273 2136 }
23274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10219376 times.
10219376 else if(types[i]==cCAVE2B)
23275 {
23276 types[i]=cCAVE2;
23277 index=1;
23278 warpsfx2 = combobuf[cids[i]].attribytes[0];
23279 }
23280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10219376 times.
10219376 else if(types[i]==cCAVE2C)
23281 {
23282 types[i]=cCAVE2;
23283 warpsfx2 = combobuf[cids[i]].attribytes[0];
23284 index=2;
23285 }
23286
1/2
✓ Branch 0 taken 10219376 times.
✗ Branch 1 not taken.
10219376 else if(types[i]==cCAVE2D)
23287 {
23288 types[i]=cCAVE2;
23289 warpsfx2 = combobuf[cids[i]].attribytes[0];
23290 index=3;
23291 }
23292
23293
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 10221436 times.
10221512 if(types[i]==cSWIMWARP)
23294 {
23295 76 index=0;
23296 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
23297 76 }
23298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10221436 times.
10221436 else if(types[i]==cSWIMWARPB)
23299 {
23300 types[i]=cSWIMWARP;
23301 warpsfx2 = combobuf[cids[i]].attribytes[0];
23302 index=1;
23303 }
23304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10221436 times.
10221436 else if(types[i]==cSWIMWARPC)
23305 {
23306 types[i]=cSWIMWARP;
23307 warpsfx2 = combobuf[cids[i]].attribytes[0];
23308 index=2;
23309 }
23310
1/2
✓ Branch 0 taken 10221436 times.
✗ Branch 1 not taken.
10221436 else if(types[i]==cSWIMWARPD)
23311 {
23312 types[i]=cSWIMWARP;
23313 warpsfx2 = combobuf[cids[i]].attribytes[0];
23314 index=3;
23315 }
23316
23317
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 10221004 times.
10221512 if(types[i]==cDIVEWARP)
23318 {
23319 508 index=0;
23320 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
23321 508 }
23322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10221004 times.
10221004 else if(types[i]==cDIVEWARPB)
23323 {
23324 types[i]=cDIVEWARP;
23325 warpsfx2 = combobuf[cids[i]].attribytes[0];
23326 index=1;
23327 }
23328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10221004 times.
10221004 else if(types[i]==cDIVEWARPC)
23329 {
23330 types[i]=cDIVEWARP;
23331 warpsfx2 = combobuf[cids[i]].attribytes[0];
23332 index=2;
23333 }
23334
1/2
✓ Branch 0 taken 10221004 times.
✗ Branch 1 not taken.
10221004 else if(types[i]==cDIVEWARPD)
23335 {
23336 types[i]=cDIVEWARP;
23337 warpsfx2 = combobuf[cids[i]].attribytes[0];
23338 index=3;
23339 }
23340
23341
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 10220822 times.
10221512 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
23342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220822 times.
10220822 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
23343
2/2
✓ Branch 0 taken 10220806 times.
✓ Branch 1 taken 16 times.
10220822 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
23344 10221512 }
23345
23346 // Special case for step combos; otherwise, they act oddly in some cases
23347
8/8
✓ Branch 0 taken 2389504 times.
✓ Branch 1 taken 166121 times.
✓ Branch 2 taken 2370330 times.
✓ Branch 3 taken 19174 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 185212 times.
✓ Branch 6 taken 27937 times.
✓ Branch 7 taken 27854 times.
2555625 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
23348 {
23349
7/8
✓ Branch 0 taken 2325944 times.
✓ Branch 1 taken 16449 times.
✓ Branch 2 taken 2325944 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 640 times.
✓ Branch 5 taken 2325304 times.
✓ Branch 6 taken 137 times.
✓ Branch 7 taken 503 times.
2398267 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
23350 2325807 type = types[1];
23351 2342393 }
23352
23353 //Generic Step
23354
7/8
✓ Branch 0 taken 2536556 times.
✓ Branch 1 taken 18903 times.
✓ Branch 2 taken 2536556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 643 times.
✓ Branch 5 taken 2535913 times.
✓ Branch 6 taken 140 times.
✓ Branch 7 taken 503 times.
2555459 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
23355 {
23356 int32_t poses[4];
23357 int32_t sensPoses[4];
23358 2536416 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
23359 2536416 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
23360
4/6
✓ Branch 0 taken 1676432 times.
✓ Branch 1 taken 859984 times.
✓ Branch 2 taken 1676432 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1676432 times.
2536416 if(diagonalMovement||NO_GRIDLOCK)
23361 859984 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
23362 1676432 else getPoses(poses, tx, ty, tx+15, ty+15);
23363 2536416 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
23364 2536416 bool hasStep[4] = {false};
23365
2/2
✓ Branch 0 taken 10145664 times.
✓ Branch 1 taken 2536416 times.
12682080 for(auto p = 0; p < 4; ++p)
23366 {
23367
2/2
✓ Branch 0 taken 10143372 times.
✓ Branch 1 taken 71005896 times.
81149268 for(auto lyr = 0; lyr < 7; ++lyr)
23368 {
23369
2/2
✓ Branch 0 taken 33029639 times.
✓ Branch 1 taken 37976257 times.
71005896 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23370
4/4
✓ Branch 0 taken 33029639 times.
✓ Branch 1 taken 37976257 times.
✓ Branch 2 taken 2292 times.
✓ Branch 3 taken 71003604 times.
71005896 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
23371 71005896 || types[p] == cSTEP)
23372 {
23373 2292 hasStep[p] = true;
23374 2292 break;
23375 }
23376 71003604 }
23377 10145664 }
23378 2536416 bool canNormalStep = true;
23379
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 2538932 times.
2539719 for(auto p = 0; p < 4; ++p)
23380 {
23381
2/2
✓ Branch 0 taken 2537093 times.
✓ Branch 1 taken 1839 times.
2538932 if(poses[p] < 0) continue;
23382
2/2
✓ Branch 0 taken 1464 times.
✓ Branch 1 taken 2535629 times.
2537093 if(!hasStep[p])
23383 {
23384 2535629 canNormalStep = false;
23385 2535629 break;
23386 }
23387 1464 }
23388
2/2
✓ Branch 0 taken 10145664 times.
✓ Branch 1 taken 2536416 times.
12682080 for(auto p = 0; p < 4; ++p)
23389 {
23390
2/2
✓ Branch 0 taken 71019648 times.
✓ Branch 1 taken 10145664 times.
81165312 for(auto lyr = 0; lyr < 7; ++lyr)
23391 {
23392
2/2
✓ Branch 0 taken 33041477 times.
✓ Branch 1 taken 37978171 times.
71019648 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
23393
2/2
✓ Branch 0 taken 29997506 times.
✓ Branch 1 taken 41022142 times.
71019648 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
23394
6/6
✓ Branch 0 taken 22036 times.
✓ Branch 1 taken 70997612 times.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 12593 times.
✓ Branch 4 taken 9425 times.
✓ Branch 5 taken 18 times.
71019648 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
23395 {
23396 18 do_trigger_combo(lyr,poses[p]);
23397
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 11 times.
18 if(poses[p] == sensPoses[p]) continue;
23398 11 }
23399
4/4
✓ Branch 0 taken 29997499 times.
✓ Branch 1 taken 41022142 times.
✓ Branch 2 taken 29995286 times.
✓ Branch 3 taken 2213 times.
71019641 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
23400 {
23401 2213 do_trigger_combo(lyr,sensPoses[p]);
23402 2213 }
23403 71019641 }
23404 10145664 }
23405 2536416 word c = tmpscr->numFFC();
23406
2/2
✓ Branch 0 taken 77020841 times.
✓ Branch 1 taken 2536416 times.
79557257 for(word i=0; i<c; i++)
23407 {
23408 77020841 bool found = false;
23409
2/2
✓ Branch 0 taken 154041682 times.
✓ Branch 1 taken 77020841 times.
231062523 for(auto xch = 0; xch < 2; ++xch)
23410 {
23411
2/2
✓ Branch 0 taken 308083364 times.
✓ Branch 1 taken 154041682 times.
462125046 for(auto ych = 0; ych < 2; ++ych)
23412 {
23413
2/2
✓ Branch 0 taken 307944480 times.
✓ Branch 1 taken 138884 times.
308083364 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
23414 {
23415 138884 found = true;
23416 138884 }
23417 308083364 }
23418 154041682 }
23419
2/2
✓ Branch 0 taken 76969585 times.
✓ Branch 1 taken 51256 times.
77020841 if (found)
23420 {
23421 51256 ffcdata& ffc = tmpscr->ffcs[i];
23422 51256 newcombo const* cmb = &combobuf[ffc.getData()];
23423
1/2
✓ Branch 0 taken 51256 times.
✗ Branch 1 not taken.
51256 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
23424 {
23425 do_trigger_combo_ffc(i);
23426 }
23427 51256 }
23428 77020841 }
23429 2536416 }
23430
2/2
✓ Branch 0 taken 2554283 times.
✓ Branch 1 taken 1176 times.
2555459 if(isDiving()) //Dive-> triggerflag
23431 {
23432 1176 int pos = COMBOPOS(x+8,y+8);
23433 1176 int x1=x,x2=x+15,y1=y+(bigHitbox?0:8),y2=y+15;
23434 1176 int xposes[] = {x1,x1,x2,x2};
23435 1176 int yposes[] = {y1,y2,y1,y2};
23436 int32_t poses[4];
23437 1176 getPoses(poses,x1,y1,x2,y2);
23438
2/2
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 1176 times.
9408 for(auto lyr = 0; lyr < 7; ++lyr)
23439 {
23440 8232 mapscr* s = FFCore.tempScreens[lyr];
23441 8232 newcombo const& cmb = combobuf[s->data[pos]];
23442 8232 bool didtrig = false;
23443
1/2
✓ Branch 0 taken 8232 times.
✗ Branch 1 not taken.
8232 if (cmb.triggerflags[3] & combotriggerDIVETRIG)
23444 {
23445 do_trigger_combo(lyr,pos);
23446 didtrig = true;
23447 }
23448
2/2
✓ Branch 0 taken 32928 times.
✓ Branch 1 taken 8232 times.
41160 for(auto q = 0; q < 4; ++q)
23449 {
23450
2/2
✓ Branch 0 taken 20412 times.
✓ Branch 1 taken 12516 times.
32928 if(poses[q] < 0) continue;
23451
3/4
✓ Branch 0 taken 8232 times.
✓ Branch 1 taken 12180 times.
✓ Branch 2 taken 8232 times.
✗ Branch 3 not taken.
20412 if(poses[q] == pos && didtrig) continue;
23452 20412 newcombo const& cmb = combobuf[s->data[poses[q]]];
23453
1/2
✓ Branch 0 taken 20412 times.
✗ Branch 1 not taken.
20412 if (cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
23454 do_trigger_combo(lyr,poses[q]);
23455 20412 }
23456 8232 }
23457 1176 word c = tmpscr->numFFC();
23458
2/2
✓ Branch 0 taken 37632 times.
✓ Branch 1 taken 1176 times.
38808 for(word i=0; i<c; i++)
23459 {
23460 37632 ffcdata& ffc = tmpscr->ffcs[i];
23461 37632 newcombo const& cmb = combobuf[ffc.getData()];
23462
2/4
✓ Branch 0 taken 37632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37632 times.
37632 if ((cmb.triggerflags[3] & combotriggerDIVETRIG) && ffcIsAt(i, x+8, y+8))
23463 {
23464 do_trigger_combo_ffc(i);
23465 }
23466
1/2
✓ Branch 0 taken 37632 times.
✗ Branch 1 not taken.
37632 else if(cmb.triggerflags[3] & combotriggerDIVESENSTRIG)
23467 {
23468 for(auto q = 0; q < 4; ++q)
23469 {
23470 if(ffcIsAt(i, xposes[q], yposes[q]))
23471 {
23472 do_trigger_combo_ffc(i);
23473 break;
23474 }
23475 }
23476 }
23477 37632 }
23478 1176 }
23479
23480 //
23481 // Now, let's check for Save combos...
23482 //
23483 2555459 x1 = tx+4;
23484 2555459 x2 = tx+11;
23485 2555459 y1 = ty+4;
23486 2555459 y2 = ty+11;
23487
23488 2555459 types[0] = COMBOTYPE(x1,y1);
23489 2555459 cids[0] = MAPCOMBO(x1,y1);
23490
23491
2/2
✓ Branch 0 taken 2519344 times.
✓ Branch 1 taken 36115 times.
2555459 if(MAPFFCOMBO(x1,y1))
23492 {
23493 36115 types[0] = FFCOMBOTYPE(x1,y1);
23494 36115 cids[0] = MAPFFCOMBO(x1,y1);
23495 36115 }
23496
23497 2555459 types[1] = COMBOTYPE(x1,y2);
23498 2555459 cids[1] = MAPCOMBO(x1,y2);
23499
23500
2/2
✓ Branch 0 taken 2524439 times.
✓ Branch 1 taken 31020 times.
2555459 if(MAPFFCOMBO(x1,y2))
23501 {
23502 31020 types[1] = FFCOMBOTYPE(x1,y2);
23503 31020 cids[1] = MAPFFCOMBO(x1,y2);
23504 31020 }
23505
23506 2555459 types[2] = COMBOTYPE(x2,y1);
23507 2555459 cids[2] = MAPCOMBO(x2,y1);
23508
23509
2/2
✓ Branch 0 taken 2519269 times.
✓ Branch 1 taken 36190 times.
2555459 if(MAPFFCOMBO(x2,y1))
23510 {
23511 36190 types[2] = FFCOMBOTYPE(x2,y1);
23512 36190 cids[2] = MAPFFCOMBO(x2,y1);
23513 36190 }
23514
23515 2555459 types[3] = COMBOTYPE(x2,y2);
23516 2555459 cids[3] = MAPCOMBO(x2,y2);
23517
23518
2/2
✓ Branch 0 taken 2524322 times.
✓ Branch 1 taken 31137 times.
2555459 if(MAPFFCOMBO(x2,y2))
23519 {
23520 31137 types[3] = FFCOMBOTYPE(x2,y2);
23521 31137 cids[3] = MAPFFCOMBO(x2,y2);
23522 31137 }
23523
23524
23525
2/2
✓ Branch 0 taken 2555459 times.
✓ Branch 1 taken 10221836 times.
12777295 for(int32_t i=0; i<4; i++)
23526 {
23527
2/2
✓ Branch 0 taken 10221512 times.
✓ Branch 1 taken 324 times.
10221836 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23528 {
23529
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
23530 {
23531 types[i] = cNONE;
23532 setsave = false;
23533 break;
23534 }
23535 324 }
23536
2/2
✓ Branch 0 taken 10220550 times.
✓ Branch 1 taken 1286 times.
10221836 if(types[i]==cSAVE) setsave=true;
23537
23538
1/2
✓ Branch 0 taken 10221836 times.
✗ Branch 1 not taken.
10221836 if(types[i]==cSAVE2) setsave=true;
23539 10221836 }
23540
23541
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 2555028 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
2555459 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
23542 {
23543 229 last_savepoint_id = cids[0];
23544 229 type = types[0];
23545 229 }
23546 //
23547 // Now, let's check for Drowning combos...
23548 //
23549
3/4
✓ Branch 0 taken 1798073 times.
✓ Branch 1 taken 757386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1798073 times.
2555459 if(get_qr(qr_DROWN) || CanSideSwim())
23550 {
23551 757386 y1 = ty+9;
23552 757386 y2 = ty+15;
23553
2/2
✓ Branch 0 taken 227871 times.
✓ Branch 1 taken 529515 times.
757386 if (get_qr(qr_SMARTER_WATER))
23554 {
23555
4/4
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 225990 times.
✓ Branch 2 taken 1597 times.
✓ Branch 3 taken 3 times.
229471 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
23556
2/2
✓ Branch 0 taken 1725 times.
✓ Branch 1 taken 156 times.
1881 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
23557
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 125 times.
1725 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
23558 1600 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
23559 227871 }
23560 else
23561 {
23562 529515 types[0] = COMBOTYPE(x1,y1);
23563
23564
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 518214 times.
529515 if(MAPFFCOMBO(x1,y1))
23565 11301 types[0] = FFCOMBOTYPE(x1,y1);
23566
23567 529515 types[1] = COMBOTYPE(x1,y2);
23568
23569
2/2
✓ Branch 0 taken 10868 times.
✓ Branch 1 taken 518647 times.
529515 if(MAPFFCOMBO(x1,y2))
23570 10868 types[1] = FFCOMBOTYPE(x1,y2);
23571
23572 529515 types[2] = COMBOTYPE(x2,y1);
23573
23574
2/2
✓ Branch 0 taken 12015 times.
✓ Branch 1 taken 517500 times.
529515 if(MAPFFCOMBO(x2,y1))
23575 12015 types[2] = FFCOMBOTYPE(x2,y1);
23576
23577 529515 types[3] = COMBOTYPE(x2,y2);
23578
23579
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 518157 times.
529515 if(MAPFFCOMBO(x2,y2))
23580 11358 types[3] = FFCOMBOTYPE(x2,y2);
23581
23582 529515 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
23583
2/2
✓ Branch 0 taken 11562 times.
✓ Branch 1 taken 517953 times.
529515 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
23584 11562 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
23585
23586
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 527623 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1852 times.
531367 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
23587
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
23588 1852 water = typec;
23589 }
23590 757386 }
23591
23592
23593 // Pits have a bigger 'hitbox' than stairs...
23594 2555459 x1 = tx+7;
23595 2555459 x2 = tx+8;
23596 2555459 y1 = ty+7+(bigHitbox?0:4);
23597 2555459 y2 = ty+8+(bigHitbox?0:4);
23598
23599 2555459 types[0] = COMBOTYPE(x1,y1);
23600 2555459 cids[0] = MAPCOMBO(x1,y1);
23601
23602
2/2
✓ Branch 0 taken 2524122 times.
✓ Branch 1 taken 31337 times.
2555459 if(MAPFFCOMBO(x1,y1))
23603 {
23604 31337 types[0] = FFCOMBOTYPE(x1,y1);
23605 31337 cids[0] = MAPFFCOMBO(x1,y1);
23606 31337 }
23607
23608 2555459 types[1] = COMBOTYPE(x1,y2);
23609 2555459 cids[1] = MAPCOMBO(x1,y2);
23610
23611
2/2
✓ Branch 0 taken 2524133 times.
✓ Branch 1 taken 31326 times.
2555459 if(MAPFFCOMBO(x1,y2))
23612 {
23613 31326 types[1] = FFCOMBOTYPE(x1,y2);
23614 31326 cids[1] = MAPFFCOMBO(x1,y2);
23615 31326 }
23616 2555459 types[2] = COMBOTYPE(x2,y1);
23617 2555459 cids[2] = MAPCOMBO(x2,y1);
23618
23619
2/2
✓ Branch 0 taken 2524470 times.
✓ Branch 1 taken 30989 times.
2555459 if(MAPFFCOMBO(x2,y1))
23620 {
23621 30989 types[2] = FFCOMBOTYPE(x2,y1);
23622 30989 cids[2] = MAPFFCOMBO(x2,y1);
23623 30989 }
23624
23625 2555459 types[3] = COMBOTYPE(x2,y2);
23626 2555459 cids[3] = MAPCOMBO(x2,y2);
23627
23628
2/2
✓ Branch 0 taken 2524544 times.
✓ Branch 1 taken 30915 times.
2555459 if(MAPFFCOMBO(x2,y2))
23629 {
23630 30915 types[3] = FFCOMBOTYPE(x2,y2);
23631 30915 cids[3] = MAPFFCOMBO(x2,y2);
23632 30915 }
23633
23634
2/2
✓ Branch 0 taken 10221836 times.
✓ Branch 1 taken 2555459 times.
12777295 for(int32_t i=0; i<4; i++)
23635 {
23636
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 10221572 times.
10221836 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
23637 {
23638 264 types[i] = cNONE;
23639 264 continue;
23640 }
23641
2/2
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 10220300 times.
10221572 if(types[i]==cPIT)
23642 {
23643 1272 index=0;
23644 1272 warpsfx2 = combobuf[cids[i]].attribytes[0];
23645 1272 }
23646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220300 times.
10220300 else if(types[i]==cPITB)
23647 {
23648 types[i]=cPIT;
23649 index=1;
23650 warpsfx2 = combobuf[cids[i]].attribytes[0];
23651 }
23652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10220300 times.
10220300 else if(types[i]==cPITC)
23653 {
23654 types[i]=cPIT;
23655 index=2;
23656 warpsfx2 = combobuf[cids[i]].attribytes[0];
23657 }
23658
1/2
✓ Branch 0 taken 10220300 times.
✗ Branch 1 not taken.
10220300 else if(types[i]==cPITD)
23659 {
23660 types[i]=cPIT;
23661 index=3;
23662 warpsfx2 = combobuf[cids[i]].attribytes[0];
23663 }
23664 10221572 }
23665
23666
6/8
✓ Branch 0 taken 2555137 times.
✓ Branch 1 taken 322 times.
✓ Branch 2 taken 2555137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2555093 times.
✓ Branch 5 taken 44 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2555093 times.
2555459 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
23667
3/8
✓ Branch 0 taken 366 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 366 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 366 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
732 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_qr(qr_MSGFREEZE)))
23668 366 type=cPIT;
23669
23670 //
23671 // Time to act on our results for type, flag, flag2 and flag3...
23672 //
23673
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 2555230 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
2555459 if(type==cSAVE&&currscr<128)
23674 229 *ls=1;
23675
23676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2555459 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2555459 if(type==cSAVE2&&currscr<128)
23677 *ls=2;
23678
23679
7/8
✓ Branch 0 taken 2546909 times.
✓ Branch 1 taken 8550 times.
✓ Branch 2 taken 2533781 times.
✓ Branch 3 taken 13128 times.
✓ Branch 4 taken 2533251 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2533251 times.
2555459 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
23680 {
23681 22208 fairycircle(REFILL_LIFE);
23682
23683
2/2
✓ Branch 0 taken 18756 times.
✓ Branch 1 taken 3452 times.
22208 if(fairyclk!=0) return;
23684 3452 }
23685
23686
4/8
✓ Branch 0 taken 2536703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2536703 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2536703 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2536703 times.
2536703 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
23687 {
23688 fairycircle(REFILL_MAGIC);
23689
23690 if(fairyclk!=0) return;
23691 }
23692
23693
4/8
✓ Branch 0 taken 2536703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2536703 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2536703 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2536703 times.
2536703 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
23694 {
23695 fairycircle(REFILL_ALL);
23696
23697 if(fairyclk!=0) return;
23698 }
23699
23700 // Just in case Hero was moved off of the fairy flag
23701
1/2
✓ Branch 0 taken 2536703 times.
✗ Branch 1 not taken.
2536703 if(refilling==REFILL_FAIRYDONE)
23702 {
23703 fairycircle(REFILL_NONE);
23704
23705 if(fairyclk!=0) return;
23706 }
23707
23708
5/8
✓ Branch 0 taken 2536694 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 2536694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2536694 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2536694 times.
2536703 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
23709 {
23710 9 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
23711 9 win_game();
23712 9 return;
23713 }
23714
23715
4/4
✓ Branch 0 taken 2532854 times.
✓ Branch 1 taken 3840 times.
✓ Branch 2 taken 2532854 times.
✓ Branch 3 taken 3840 times.
2536694 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
23716 3840 return;
23717
23718
4/4
✓ Branch 0 taken 2531879 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 2531794 times.
2532854 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
23719 {
23720
23721
3/4
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 451 times.
✓ Branch 2 taken 609 times.
✗ Branch 3 not taken.
1060 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_qr(qr_TRIGGERSREPEAT))
23722 {
23723 1060 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
23724 1060 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
23725 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
23726
23727
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 975 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
1060 if(type==cTRIGFLAG && canPermSecret())
23728 {
23729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
23730
23731 85 hidden_entrance(0,true,false);
23732 85 }
23733 else
23734 {
23735 975 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
23736 975 hidden_entrance(0,true,only16_31);
23737 }
23738 1060 }
23739 1060 }
23740
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 2531452 times.
2531794 else if(!didstrig)
23741 {
23742 2531452 stepsecret = -1;
23743 2531452 }
23744
23745 //Better? Dock collision
23746
23747 // Drown if:
23748 // * Water (obviously walkable),
23749 // * Quest Rule allows it,
23750 // * Not on stepladder,
23751 // * Not jumping,
23752 // * Not hovering,
23753 // * Not rafting,
23754 // * Not swallowed,
23755 // * Not a dried lake.
23756
23757 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
23758
23759
13/22
✓ Branch 0 taken 3393 times.
✓ Branch 1 taken 2529461 times.
✓ Branch 2 taken 3393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3393 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3386 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3010 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3010 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3010 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
2532854 if(water > 0 && ((get_qr(qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
23760 {
23761
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3010 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23762 {
23763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!(ladderx+laddery)) drownCombo = water;
23764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (combobuf[water].usrflags&cflag1) Drown(1);
23765 10 else Drown();
23766
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if(byte drown_sfx = combobuf[water].attribytes[4])
23767 8 sfx(drown_sfx, pan(int32_t(x)));
23768 10 }
23769
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
23770 {
23771 109 SetSwim();
23772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
23773 109 landswim=0;
23774 109 return;
23775 }
23776 2901 }
23777
23778
23779
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 2532582 times.
2532745 if(type==cSTEP)
23780 {
23781 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
23782
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
23783 {
23784 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
23785
23786 if
23787 (
23788
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
23789
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
23790 && /*HEAVY*/
23791
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23792 )
23793
23794 {
23795 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
23796 62 tmpscr->data[stepnext]++;
23797
23798 62 }
23799
23800 if
23801 (
23802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
23803 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23804 && /*HEAVY*/
23805 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23806 )
23807 {
23808 int32_t stepc = tmpscr->data[stepnext];
23809 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23810 for(int32_t k=0; k<176; k++)
23811 {
23812 if(tmpscr->data[k]==stepc)
23813 {
23814 tmpscr->data[k]++;
23815 }
23816 }
23817 }
23818
23819 if
23820 (
23821
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
23822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
23823 && /*HEAVY*/
23824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
23825 )
23826 {
23827 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
23828
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
23829 {
23830 if(
23831
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
23832
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
23833
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
23834 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
23835 )
23836 {
23837 21 tmpscr->data[k]++;
23838 21 }
23839 528 }
23840 3 }
23841 66 }
23842 163 }
23843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2532582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2532582 else if(type==cSTEPSFX && action == walking)
23844 {
23845 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
23846 }
23847 2532582 else stepnext = -1;
23848
23849 2532745 detail_int[0]=tx;
23850 2532745 detail_int[1]=ty;
23851
23852
23853
8/8
✓ Branch 0 taken 2532512 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 426 times.
✓ Branch 3 taken 2532319 times.
✓ Branch 4 taken 2531411 times.
✓ Branch 5 taken 908 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8 times.
2532758 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
23854
5/6
✓ Branch 0 taken 2531045 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 2531034 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 2531034 times.
✗ Branch 5 not taken.
2531411 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
23855
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2531021 times.
2531034 !(type==cDIVEWARP && isDiving()))
23856 2531029 {
23857 RaftingStuff:
23858
2/2
✓ Branch 0 taken 2530470 times.
✓ Branch 1 taken 559 times.
2531029 if (get_qr(qr_BETTER_RAFT_2))
23859 {
23860 559 bool doraft = true;
23861
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
23862 {
23863
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23864 {
23865 3 doraft = false;
23866 3 }
23867 3 }
23868 //if (mfRAFT)
23869 int32_t rafttypes[2];
23870 559 int32_t raftx1 = tx+6;
23871 559 int32_t raftx2 = tx+9;
23872 559 int32_t rafty = ty+11;
23873 int32_t raftflags[3];
23874 559 rafttypes[0]=rafttypes[1]=-1;
23875 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
23876 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
23877 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
23878
23879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23880 559 raftflags[0] = rafttypes[0];
23881
23882
23883 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
23884 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
23885
23886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23887 559 raftflags[1] = rafttypes[0];
23888
23889 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
23890 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
23891
23892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
23893 559 raftflags[2] = rafttypes[0];
23894
23895
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
23896 {
23897
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
23898 {
23899 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
23900 {
23901 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
23902 {
23903 reset_swordcharge();
23904 action=rafting; FFCore.setHeroAction(rafting);
23905 raftclk=0;
23906 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23907 else sfx(tmpscr->secretsfx);
23908 }
23909 else if (get_qr(qr_BETTER_RAFT) && doraft)
23910 {
23911 for (int32_t i = 0; i < 4; ++i)
23912 {
23913 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
23914 {
23915 reset_swordcharge();
23916 action=rafting; FFCore.setHeroAction(rafting);
23917 raftclk=0;
23918 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23919 else sfx(tmpscr->secretsfx);
23920 dir = i;
23921 break;
23922 }
23923 }
23924 }
23925 }
23926 }
23927 1677 }
23928 559 }
23929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2531029 times.
2531029 if (RaftPass) return;
23930
3/3
✓ Branch 0 taken 12213 times.
✓ Branch 1 taken 2518107 times.
✓ Branch 2 taken 709 times.
2531029 switch(flag)
23931 {
23932 case mfDIVE_ITEM:
23933
6/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
709 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23934 {
23935 18 additem(x, y, tmpscr->catchall,
23936 9 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23937 9 sfx(tmpscr->secretsfx);
23938 9 }
23939
23940 709 return;
23941
23942 case mfRAFT:
23943 case mfRAFT_BRANCH:
23944
23945 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
23946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12213 times.
12213 if (!get_qr(qr_BETTER_RAFT_2))
23947 {
23948 12213 bool doraft = true;
23949
5/6
✓ Branch 0 taken 12213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 964 times.
✓ Branch 3 taken 11249 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 826 times.
12213 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
23950 {
23951
5/6
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 392 times.
✓ Branch 3 taken 434 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 374 times.
826 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
23952 {
23953 374 doraft = false;
23954 374 }
23955 826 }
23956
13/16
✓ Branch 0 taken 10232 times.
✓ Branch 1 taken 1981 times.
✓ Branch 2 taken 1936 times.
✓ Branch 3 taken 8296 times.
✓ Branch 4 taken 1926 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1923 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 1923 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1923 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1923 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1262 times.
✓ Branch 15 taken 661 times.
12213 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
23957 {
23958
3/4
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 471 times.
661 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
23959 {
23960 190 reset_swordcharge();
23961 190 action=rafting; FFCore.setHeroAction(rafting);
23962 190 raftclk=0;
23963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23964 190 else sfx(tmpscr->secretsfx);
23965 190 }
23966
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
471 else if (get_qr(qr_BETTER_RAFT) && doraft)
23967 {
23968 for (int32_t i = 0; i < 4; ++i)
23969 {
23970 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
23971 {
23972 reset_swordcharge();
23973 action=rafting; FFCore.setHeroAction(rafting);
23974 raftclk=0;
23975 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
23976 else sfx(tmpscr->secretsfx);
23977 dir = i;
23978 break;
23979 }
23980 }
23981 }
23982 661 }
23983 12213 }
23984
23985 12213 return;
23986
23987 default:
23988 2518107 break;
23989 //return;
23990 }
23991
23992
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2518107 times.
✗ Branch 2 not taken.
2518107 switch(flag2)
23993 {
23994 case mfDIVE_ITEM:
23995 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
23996 {
23997 additem(x, y, tmpscr->catchall,
23998 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
23999 sfx(tmpscr->secretsfx);
24000 }
24001
24002 return;
24003
24004 case mfRAFT:
24005 case mfRAFT_BRANCH:
24006
24007 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
24008 if (!get_qr(qr_BETTER_RAFT_2))
24009 {
24010 bool doraft = true;
24011 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
24012 {
24013 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
24014 {
24015 doraft = false;
24016 }
24017 }
24018 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
24019 {
24020 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
24021 {
24022 reset_swordcharge();
24023 action=rafting; FFCore.setHeroAction(rafting);
24024 raftclk=0;
24025 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
24026 else sfx(tmpscr->secretsfx);
24027 }
24028 else if (get_qr(qr_BETTER_RAFT) && doraft)
24029 {
24030 for (int32_t i = 0; i < 4; ++i)
24031 {
24032 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
24033 {
24034 reset_swordcharge();
24035 action=rafting; FFCore.setHeroAction(rafting);
24036 raftclk=0;
24037 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
24038 else sfx(tmpscr->secretsfx);
24039 dir = i;
24040 break;
24041 }
24042 }
24043 }
24044 }
24045 }
24046
24047 return;
24048
24049 default:
24050 2518107 break;
24051 //return;
24052 }
24053
24054
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2518107 times.
✗ Branch 2 not taken.
2518107 switch(flag3)
24055 {
24056 case mfDIVE_ITEM:
24057 if(isDiving() && (!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
24058 {
24059 additem(x, y, tmpscr->catchall,
24060 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
24061 sfx(tmpscr->secretsfx);
24062 }
24063
24064 return;
24065
24066 case mfRAFT:
24067 case mfRAFT_BRANCH:
24068
24069 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
24070 if (!get_qr(qr_BETTER_RAFT_2))
24071 {
24072 bool doraft = true;
24073 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
24074 {
24075 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
24076 {
24077 doraft = false;
24078 }
24079 }
24080 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
24081 {
24082 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
24083 {
24084 reset_swordcharge();
24085 action=rafting; FFCore.setHeroAction(rafting);
24086 raftclk=0;
24087 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
24088 else sfx(tmpscr->secretsfx);
24089 }
24090 else if (get_qr(qr_BETTER_RAFT) && doraft)
24091 {
24092 for (int32_t i = 0; i < 4; ++i)
24093 {
24094 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
24095 {
24096 reset_swordcharge();
24097 action=rafting; FFCore.setHeroAction(rafting);
24098 raftclk=0;
24099 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
24100 else sfx(tmpscr->secretsfx);
24101 dir = i;
24102 break;
24103 }
24104 }
24105 }
24106 }
24107 }
24108
24109 return;
24110
24111 default:
24112 2518107 return;
24113 }
24114 }
24115
24116
24117 1716 int32_t t=(currscr<128)?0:1;
24118
24119
3/4
✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 1716 times.
✗ Branch 3 not taken.
1716 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
24120
24121 //don't do this for canceled warps -DD
24122 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
24123 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
24124 {
24125 draw_screen(tmpscr);
24126 advanceframe(true);
24127 }*/
24128
24129 1716 bool skippedaframe=false;
24130
24131
6/6
✓ Branch 0 taken 1483 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 1290 times.
✓ Branch 3 taken 193 times.
✓ Branch 4 taken 908 times.
✓ Branch 5 taken 382 times.
1716 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
24132 {
24133 // Stop music only if:
24134 // * entering a Guy Cave
24135 // * warping to a DMap whose music is different.
24136
24137 1334 int32_t tdm = tmpscr[t].tilewarpdmap[index];
24138
24139
2/2
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 600 times.
1334 if(tmpscr[t].tilewarptype[index]<=wtPASS)
24140 {
24141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 734 times.
734 if (FFCore.can_dmap_change_music(tdm))
24142 {
24143
3/4
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 395 times.
734 if ((DMaps[currdmap].flags & dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
24144 395 music_stop();
24145 734 }
24146 734 }
24147 else
24148 {
24149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 if (FFCore.can_dmap_change_music(tdm))
24150 {
24151
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 4 times.
600 if (zcmusic != NULL)
24152 {
24153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if (strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
24154 (zcmusic->type == ZCMF_GME && zcmusic->track != DMaps[tdm].tmusictrack))
24155 4 music_stop();
24156 4 }
24157
2/4
✓ Branch 0 taken 596 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 596 times.
596 else if (DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi - ZC_MIDI_COUNT + 4) &&
24158 596 TheMaps[(DMaps[tdm].map * MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi - ZC_MIDI_COUNT + 4))
24159 596 music_stop();
24160 600 }
24161 }
24162
24163 1334 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24164
5/6
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 395 times.
✓ Branch 3 taken 339 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 395 times.
1334 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
24165 995 ? false : COOLSCROLL);
24166
24167 1334 FFCore.warpScriptCheck();
24168 1334 draw_screen(tmpscr);
24169 1334 advanceframe(true);
24170
24171 1334 skippedaframe=true;
24172
24173
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 1141 times.
1334 if(type==cCAVE2) walkup2(opening);
24174
2/2
✓ Branch 0 taken 908 times.
✓ Branch 1 taken 233 times.
1141 else if(type==cCAVE) walkdown(opening);
24175 1334 }
24176
24177
2/2
✓ Branch 0 taken 1350 times.
✓ Branch 1 taken 366 times.
1716 if(type==cPIT)
24178 {
24179 366 didpit=true;
24180 366 pitx=x;
24181 366 pity=y;
24182 366 warp_sound = warpsfx2;
24183 366 }
24184
24185
5/6
✓ Branch 0 taken 835 times.
✓ Branch 1 taken 881 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
1772 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
24186
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
835 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
24187 {
24188
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!skippedaframe)
24189 {
24190 FFCore.warpScriptCheck();
24191 draw_screen(tmpscr);
24192 advanceframe(true);
24193 }
24194
24195 // "take any road you want"
24196
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 11 times.
56 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
24197 56 int32_t code = WARPCODE(currdmap,homescr,dw);
24198
24199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(code>-1)
24200 {
24201 56 bool changedlevel = false;
24202 56 bool changeddmap = false;
24203
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(currdmap != code>>8)
24204 {
24205 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24206 15 changeddmap = true;
24207 15 }
24208
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(dlevel != DMaps[code>>8].level)
24209 {
24210 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24211 changedlevel = true;
24212 }
24213 56 currdmap = code>>8;
24214 56 dlevel = DMaps[currdmap].level;
24215
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(changeddmap)
24216 {
24217 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24218 15 }
24219
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(changedlevel)
24220 {
24221 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24222 }
24223
24224 56 currmap = DMaps[currdmap].map;
24225 56 homescr = (code&0xFF) + DMaps[currdmap].xoff;
24226 56 init_dmap();
24227
24228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(canPermSecret())
24229 56 setmapflag(mSECRET);
24230 56 }
24231
24232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(specialcave==STAIRCAVE) exitcave();
24233
24234 56 return;
24235 }
24236
24237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1660 times.
1660 if(type==cRESET)
24238 {
24239 if(!skippedaframe)
24240 {
24241 FFCore.warpScriptCheck();
24242 draw_screen(tmpscr);
24243 advanceframe(true);
24244 }
24245
24246 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
24247
24248 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
24249
24250 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
24251
24252 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
24253
24254 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
24255
24256 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
24257
24258 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
24259
24260 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
24261
24262 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
24263
24264 if(isdungeon())
24265 {
24266 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
24267
24268 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
24269
24270 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
24271
24272 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
24273 }
24274
24275 didpit=true;
24276 pitx=x;
24277 pity=y;
24278 sdir=dir;
24279 dowarp(4,0, warpsfx2);
24280 }
24281 else
24282 {
24283
3/4
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 382 times.
1660 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
24284 {
24285 382 FFCore.warpScriptCheck();
24286 382 draw_screen(tmpscr);
24287 382 advanceframe(true);
24288 382 }
24289
24290 1660 sdir = dir;
24291 1660 dowarp(0,index, warpsfx2);
24292 }
24293 7247425 }
24294
24295 67 int32_t selectWlevel(int32_t d)
24296 {
24297
1/2
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
67 if(TriforceCount()==0)
24298 return 0;
24299
24300 67 word l = game->get_wlevel();
24301
24302 67 do
24303 {
24304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
121 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
24305 break;
24306
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 52 times.
121 else if(d<0)
24307
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
52 l = (l==0) ? 7 : l-1;
24308 else
24309
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 58 times.
69 l = (l==7) ? 0 : l+1;
24310
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 67 times.
121 }
24311 121 while(!(game->lvlitems[l+1] & liTRIFORCE));
24312
24313 67 game->set_wlevel(l);
24314 67 return l;
24315 67 }
24316
24317 // Would someone tell the Dodongos to shut their yaps?!
24318 13549 void kill_enemy_sfx()
24319 {
24320
2/2
✓ Branch 0 taken 13549 times.
✓ Branch 1 taken 25827 times.
39376 for(int32_t i=0; i<guys.Count(); i++)
24321 {
24322
2/2
✓ Branch 0 taken 8742 times.
✓ Branch 1 taken 17085 times.
25827 if(((enemy*)guys.spr(i))->bgsfx)
24323 17085 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
24324 25827 }
24325
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 13483 times.
13549 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
24326
2/2
✓ Branch 0 taken 13536 times.
✓ Branch 1 taken 13 times.
13549 if(tmpscr->room==rGANON)
24327 13 stop_sfx(WAV_ROAR);
24328 13549 }
24329
24330 bool HeroClass::HasHeavyBoots()
24331 {
24332 for ( int32_t q = 0; q < MAXITEMS; ++q )
24333 {
24334 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
24335 }
24336 return false;
24337 }
24338
24339 static bool refresh_dmap_scrollscript = false;
24340 2858 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
24341 {
24342 2858 refresh_dmap_scrollscript = false;
24343 2858 byte reposition_sword_postwarp = 0;
24344
1/2
✓ Branch 0 taken 2858 times.
✗ Branch 1 not taken.
2858 if(index<0)
24345 {
24346 return false;
24347 }
24348 2858 is_warping = true;
24349
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 2858 times.
3130 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
24350 {
24351 272 weapon *swd=NULL;
24352 272 swd = (weapon*)Lwpns.spr(q);
24353
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 11 times.
272 if(swd->id == (attack==wSword ? wSword : wWand))
24354 {
24355 11 Lwpns.del(q);
24356 11 }
24357 272 }
24358
24359 2858 attackclk = charging = spins = tapping = 0;
24360 2858 attack = none;
24361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2858 times.
2858 if ( warp_sound > 0 ) warpsfx = warp_sound;
24362 2858 warp_sound = 0;
24363 2858 word wdmap=0;
24364 2858 byte wscr=0,wtype=0,t=0;
24365 2858 bool overlay=false;
24366 2858 t=(currscr<128)?0:1;
24367 2858 int32_t wrindex = 0;
24368 2858 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
24369
24370 // Drawing commands probably shouldn't carry over...
24371
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 2746 times.
2858 if ( !get_qr(qr_SCRIPTDRAWSINWARPS) )
24372 2746 script_drawing_commands.Clear();
24373
24374
4/6
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1663 times.
✓ Branch 2 taken 1017 times.
✓ Branch 3 taken 66 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2858 switch(type)
24375 {
24376 case 0: // tile warp
24377 1663 wtype = tmpscr[t].tilewarptype[index];
24378 1663 wdmap = tmpscr[t].tilewarpdmap[index];
24379 1663 wscr = tmpscr[t].tilewarpscr[index];
24380 1663 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
24381 1663 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
24382 1663 break;
24383
24384 case 1: // side warp
24385 1017 wtype = tmpscr[t].sidewarptype[index];
24386 1017 wdmap = tmpscr[t].sidewarpdmap[index];
24387 1017 wscr = tmpscr[t].sidewarpscr[index];
24388 1017 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
24389 1017 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
24390 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
24391 //there is no doscript for screen scripts. They run like ffcs.
24392
24393 1017 break;
24394
24395 case 2: // whistle warp
24396 {
24397 66 wtype = wtWHISTLE;
24398
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
24399 66 int32_t level=0;
24400
24401
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(blowcnt==0)
24402 level = selectWlevel(0);
24403 else
24404 {
24405
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66 times.
133 for(int32_t i=0; i<abs(blowcnt); i++)
24406 67 level = selectWlevel(blowcnt);
24407 }
24408
24409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
24410 {
24411 level %= QMisc.warp[wind].size;
24412 game->set_wlevel(level);
24413 }
24414
24415 66 wdmap = QMisc.warp[wind].dmap[level];
24416 66 wscr = QMisc.warp[wind].scr[level];
24417 }
24418 66 break;
24419
24420 case 3:
24421 wtype = wtIWARP;
24422 wdmap = cheat_goto_dmap;
24423 wscr = cheat_goto_screen;
24424 break;
24425
24426 case 4:
24427 wtype = wtIWARP;
24428 wdmap = currdmap;
24429 wscr = homescr-DMaps[currdmap].xoff;
24430 break;
24431 }
24432
24433 2858 bool intradmap = (wdmap == currdmap);
24434 2858 int32_t olddmap = currdmap;
24435 2858 rehydratelake(type!=wtSCROLL);
24436 2858 bool updatemusic = FFCore.can_dmap_change_music(wdmap);
24437 2858 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
24438 2858 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
24439
24440
6/8
✓ Branch 0 taken 1168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 342 times.
✓ Branch 6 taken 66 times.
✗ Branch 7 not taken.
2858 switch(wtype)
24441 {
24442 case wtCAVE:
24443 {
24444 // cave/item room
24445 450 ALLOFF();
24446 450 homescr=currscr;
24447 450 currscr=0x80;
24448
24449
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfCAVES) // cave
24450 {
24451
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
339 if (updatemusic || !musicnocut || !get_qr(qr_SCREEN80_OWN_MUSIC))
24452 339 music_stop();
24453 339 kill_sfx();
24454
24455
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 278 times.
339 if(tmpscr->room==rWARP)
24456 {
24457 61 currscr=0x81;
24458 61 specialcave = STAIRCAVE;
24459 61 }
24460 278 else specialcave = GUYCAVE;
24461
24462 //lighting(2,dir);
24463 339 lighting(false, true);
24464 339 loadlvlpal(10);
24465
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 38 times.
640 bool b2 = COOLSCROLL&&
24466
3/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
301 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
24467
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
24468
2/4
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✗ Branch 3 not taken.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
24469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
24470 339 blackscr(30,b2?false:true);
24471 339 loadscr(0,wdmap,currscr,up,false);
24472 339 loadscr(1,wdmap,homescr,up,false);
24473 //preloaded freeform combos
24474 339 ffscript_engine(true);
24475 339 putscr(scrollbuf,0,0,tmpscr);
24476 339 putscrdoors(scrollbuf,0,0,tmpscr);
24477 339 dir=up;
24478 339 x=112;
24479 339 y=160;
24480
1/2
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
339 if(didpit)
24481 {
24482 didpit=false;
24483 x=pitx;
24484 y=pity;
24485 }
24486
24487 339 reset_hookshot();
24488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(reposition_sword_postwarp)
24489 {
24490 weapon *swd=NULL;
24491 for(int32_t i=0; i<Lwpns.Count(); i++)
24492 {
24493 swd = (weapon*)Lwpns.spr(i);
24494
24495 if(swd->id == (attack==wSword ? wSword : wWand))
24496 {
24497 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24498 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24499 positionSword(swd,item_id);
24500 break;
24501 }
24502 }
24503 }
24504 339 stepforward(diagonalMovement?5:6, false);
24505 339 }
24506 else // item room
24507 {
24508 111 specialcave = ITEMCELLAR;
24509 111 map_bkgsfx(false);
24510 111 kill_enemy_sfx();
24511 111 draw_screen(tmpscr,false);
24512
24513 //unless the room is already dark, fade to black
24514
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 110 times.
111 if(!darkroom)
24515 {
24516 110 darkroom = true;
24517 110 fade(DMaps[currdmap].color,true,false);
24518 110 }
24519
24520 111 blackscr(30,true);
24521 111 loadscr(0,wdmap,currscr,down,false);
24522 111 loadscr(1,wdmap,homescr,-1,false);
24523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=1; }
24524 111 draw_screen(tmpscr);
24525 111 fade(11,true,true);
24526 111 darkroom = false;
24527 111 dir=down;
24528 111 x=48;
24529 111 y=0;
24530
24531 // is this didpit check necessary?
24532
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(didpit)
24533 {
24534 didpit=false;
24535 x=pitx;
24536 y=pity;
24537 }
24538
24539 111 reset_hookshot();
24540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(reposition_sword_postwarp)
24541 {
24542 weapon *swd=NULL;
24543 for(int32_t i=0; i<Lwpns.Count(); i++)
24544 {
24545 swd = (weapon*)Lwpns.spr(i);
24546
24547 if(swd->id == (attack==wSword ? wSword : wWand))
24548 {
24549 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24550 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24551 positionSword(swd,item_id);
24552 break;
24553 }
24554 }
24555 }
24556 111 lighting(false, true);
24557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( dontdraw < 2 ) { dontdraw=0; }
24558 111 stepforward(diagonalMovement?16:18, false);
24559 }
24560
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
450 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
24561 {
24562 playLevelMusic();
24563 if (musicrevert)
24564 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
24565 }
24566 450 break;
24567 }
24568
24569 case wtPASS: // passageway
24570 {
24571 228 map_bkgsfx(false);
24572 228 kill_enemy_sfx();
24573 228 ALLOFF();
24574 //play sound
24575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
24576 228 homescr=currscr;
24577 228 currscr=0x81;
24578 228 specialcave = PASSAGEWAY;
24579 228 byte warpscr2 = wscr + DMaps[wdmap].xoff;
24580 228 draw_screen(tmpscr,false);
24581
24582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!get_qr(qr_NEW_DARKROOM))
24583 {
24584
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 220 times.
228 if(!darkroom)
24585 220 fade(DMaps[currdmap].color,true,false);
24586
24587 228 darkroom=true;
24588 228 }
24589 228 blackscr(30,true);
24590 228 loadscr(0,wdmap,currscr,down,false);
24591 228 loadscr(1,wdmap,homescr,-1,false);
24592 //preloaded freeform combos
24593 228 ffscript_engine(true);
24594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=1; }
24595 228 draw_screen(tmpscr);
24596 228 lighting(false, true);
24597 228 dir=down;
24598 228 x=48;
24599
24600
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 117 times.
228 if((homescr&15) > (warpscr2&15))
24601 {
24602 117 x=192;
24603 117 }
24604
24605
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4 times.
228 if((homescr&15) == (warpscr2&15))
24606 {
24607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((currscr>>4) > (warpscr2>>4))
24608 {
24609 4 x=192;
24610 4 }
24611 4 }
24612
24613 // is this didpit check necessary?
24614
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(didpit)
24615 {
24616 didpit=false;
24617 x=pitx;
24618 y=pity;
24619 }
24620
24621 228 y=0;
24622 228 set_respawn_point();
24623 228 trySideviewLadder();
24624 228 reset_hookshot();
24625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(reposition_sword_postwarp)
24626 {
24627 weapon *swd=NULL;
24628 for(int32_t i=0; i<Lwpns.Count(); i++)
24629 {
24630 swd = (weapon*)Lwpns.spr(i);
24631
24632 if(swd->id == (attack==wSword ? wSword : wWand))
24633 {
24634 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24635 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24636 positionSword(swd,item_id);
24637 break;
24638 }
24639 }
24640 }
24641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if ( dontdraw < 2 ) { dontdraw=0; }
24642 228 stepforward(diagonalMovement?16:18, false);
24643 228 newscr_clk=frame;
24644 228 activated_timed_warp=false;
24645 228 stepoutindex=index;
24646 228 stepoutscr = warpscr2;
24647 228 stepoutdmap = wdmap;
24648 228 stepoutwr=wrindex;
24649 }
24650 228 break;
24651
24652 case wtEXIT: // entrance/exit
24653 {
24654 600 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
24655 600 ALLOFF();
24656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if(updatemusic||!musicnocut)
24657 600 music_stop();
24658 600 kill_sfx();
24659 600 blackscr(30,false);
24660 600 bool changedlevel = false;
24661 600 bool changeddmap = false;
24662
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 599 times.
600 if(currdmap != wdmap)
24663 {
24664 599 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
24665 599 changeddmap = true;
24666 599 }
24667
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 582 times.
600 if(dlevel != DMaps[wdmap].level)
24668 {
24669 582 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
24670 582 changedlevel = true;
24671 582 }
24672 600 dlevel = DMaps[wdmap].level;
24673 600 currdmap = wdmap;
24674
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 599 times.
600 if(changeddmap)
24675 {
24676 599 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
24677 599 }
24678
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 582 times.
600 if(changedlevel)
24679 {
24680 582 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
24681 582 }
24682
24683 600 currmap=DMaps[currdmap].map;
24684 600 init_dmap();
24685 600 update_subscreens(wdmap);
24686 600 loadfullpal();
24687 600 ringcolor(false);
24688 600 loadlvlpal(DMaps[currdmap].color);
24689 //lastentrance_dmap = currdmap;
24690 600 homescr = currscr = wscr + DMaps[currdmap].xoff;
24691 600 loadscr(0,currdmap,currscr,-1,overlay);
24692
24693
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 597 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
600 if((tmpscr->flags&fDARK) && !get_qr(qr_NEW_DARKROOM))
24694 {
24695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_qr(qr_FADE))
24696 {
24697 interpolatedfade();
24698 }
24699 else
24700 {
24701 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24702 }
24703
24704 3 darkroom=naturaldark=true;
24705 3 }
24706 else
24707 {
24708 597 darkroom=naturaldark=false;
24709 }
24710
24711 int32_t wrx,wry;
24712
24713
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 586 times.
600 if(get_qr(qr_NOARRIVALPOINT))
24714 {
24715 14 wrx=tmpscr->warpreturnx[0];
24716 14 wry=tmpscr->warpreturny[0];
24717 14 }
24718 else
24719 {
24720 586 wrx=tmpscr->warparrivalx;
24721 586 wry=tmpscr->warparrivaly;
24722 }
24723
24724
6/6
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 548 times.
600 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24725 {
24726
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 223 times.
548 if(dlevel)
24727 {
24728 325 lastentrance = currscr;
24729 325 }
24730 else
24731 {
24732 223 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24733 }
24734
24735 548 lastentrance_dmap = wdmap;
24736 548 }
24737
24738
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 275 times.
600 if(dlevel)
24739 {
24740
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 318 times.
325 if(get_qr(qr_NOARRIVALPOINT))
24741 {
24742 7 x=tmpscr->warpreturnx[wrindex];
24743 7 y=tmpscr->warpreturny[wrindex];
24744 7 }
24745 else
24746 {
24747 318 x=tmpscr->warparrivalx;
24748 318 y=tmpscr->warparrivaly;
24749 }
24750 325 }
24751 else
24752 {
24753 275 x=tmpscr->warpreturnx[wrindex];
24754 275 y=tmpscr->warpreturny[wrindex];
24755 }
24756
24757
2/2
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 4 times.
600 if(didpit)
24758 {
24759 4 didpit=false;
24760 4 x=pitx;
24761 4 y=pity;
24762 4 }
24763
24764 600 dir=down;
24765
24766
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 584 times.
600 if(x==0) dir=right;
24767
24768
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 589 times.
600 if(x==240) dir=left;
24769
24770
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 586 times.
600 if(y==0) dir=down;
24771
24772
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 344 times.
600 if(y==160) dir=up;
24773
24774
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 275 times.
600 if(dlevel)
24775 {
24776 // reset enemy kill counts
24777
2/2
✓ Branch 0 taken 41600 times.
✓ Branch 1 taken 325 times.
41925 for(int32_t i=0; i<128; i++)
24778 {
24779 41600 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
24780 41600 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
24781 41600 }
24782 325 }
24783
24784 600 markBmap(dir^1);
24785 //preloaded freeform combos
24786 600 ffscript_engine(true);
24787
24788 600 reset_hookshot();
24789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
600 if(reposition_sword_postwarp)
24790 {
24791 weapon *swd=NULL;
24792 for(int32_t i=0; i<Lwpns.Count(); i++)
24793 {
24794 swd = (weapon*)Lwpns.spr(i);
24795
24796 if(swd->id == (attack==wSword ? wSword : wWand))
24797 {
24798 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24799 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24800 positionSword(swd,item_id);
24801 break;
24802 }
24803 }
24804 }
24805
24806
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 388 times.
600 if(isdungeon())
24807 {
24808 212 openscreen();
24809
4/4
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 172 times.
212 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
24810 172 stepforward(diagonalMovement?11:12, false);
24811 else
24812 // Didn't walk as far pre-1.93, and some quests depend on that
24813 40 stepforward(8, false);
24814 212 }
24815 else
24816 {
24817
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 365 times.
388 if(!COOLSCROLL)
24818 23 openscreen();
24819
24820 388 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
24821 388 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
24822 388 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
24823
24824
7/10
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 85 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
✓ Branch 4 taken 303 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 303 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 6 times.
388 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
24825 {
24826 91 reset_pal_cycling();
24827 91 putscr(scrollbuf,0,0,tmpscr);
24828 91 putscrdoors(scrollbuf,0,0,tmpscr);
24829 91 walkup(COOLSCROLL);
24830 91 }
24831
7/10
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 300 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 300 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
309 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
24832 {
24833 15 reset_pal_cycling();
24834 15 putscr(scrollbuf,0,0,tmpscr);
24835 15 putscrdoors(scrollbuf,0,0,tmpscr);
24836 15 walkdown2(COOLSCROLL);
24837 15 }
24838
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 13 times.
300 else if(COOLSCROLL)
24839 {
24840 287 openscreen();
24841 287 }
24842 }
24843
24844 606 show_subscreen_life=true;
24845 606 show_subscreen_numbers=true;
24846
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 606 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
606 if (updatemusic || !musicnocut)
24847 {
24848 612 playLevelMusic();
24849
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
612 if (musicrevert)
24850 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
24851 600 }
24852 606 currcset=DMaps[currdmap].color;
24853 606 dointro();
24854 606 set_respawn_point();
24855 606 trySideviewLadder();
24856
24857
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 606 times.
4206 for(int32_t i=0; i<6; i++)
24858 3600 visited[i]=-1;
24859
24860 606 break;
24861 }
24862
24863 case wtSCROLL: // scrolling warp
24864 {
24865 342 int32_t c = DMaps[currdmap].color;
24866 342 scrolling_map = currmap;
24867 342 currmap = DMaps[wdmap].map;
24868 342 update_subscreens(wdmap);
24869
24870 342 dlevel = DMaps[wdmap].level;
24871 //check if Hero has the map for the new location before updating the subscreen. ? -Z
24872 //This works only in one direction, if Hero had a map, to not having one.
24873 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
24874 342 update_subscreens(wdmap);
24875
24876 /*if ( has_item(itype_map, dlevel) )
24877 {
24878 //Blank the map during an intra-dmap scrolling warp.
24879 dlevel = -1; //a hack for the minimap. This works!! -Z
24880 }*/
24881
24882 // fix the scrolling direction, if it was a tile or instant warp
24883
2/4
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 342 times.
342 if(type==0 || type>=3)
24884 {
24885 sdir = dir;
24886 }
24887
24888 342 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
24889 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
24890
24891 342 reset_hookshot();
24892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(reposition_sword_postwarp)
24893 {
24894 weapon *swd=NULL;
24895 for(int32_t i=0; i<Lwpns.Count(); i++)
24896 {
24897 swd = (weapon*)Lwpns.spr(i);
24898
24899 if(swd->id == (attack==wSword ? wSword : wWand))
24900 {
24901 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
24902 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
24903 positionSword(swd,item_id);
24904 break;
24905 }
24906 }
24907 }
24908
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 291 times.
342 if(!intradmap)
24909 {
24910 291 homescr = currscr = wscr + DMaps[wdmap].xoff;
24911 291 init_dmap();
24912
24913 int32_t wrx,wry;
24914
24915
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 161 times.
291 if(get_qr(qr_NOARRIVALPOINT))
24916 {
24917 130 wrx=tmpscr->warpreturnx[0];
24918 130 wry=tmpscr->warpreturny[0];
24919 130 }
24920 else
24921 {
24922 161 wrx=tmpscr->warparrivalx;
24923 161 wry=tmpscr->warparrivaly;
24924 }
24925
24926
8/8
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 136 times.
✓ Branch 5 taken 155 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 130 times.
291 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
24927 {
24928
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 103 times.
130 if(dlevel)
24929 {
24930 27 lastentrance = currscr;
24931 27 }
24932 else
24933 {
24934 103 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
24935 }
24936
24937 130 lastentrance_dmap = wdmap;
24938 130 }
24939 291 }
24940
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 149 times.
342 if(DMaps[currdmap].color != c)
24941 {
24942 149 lighting(false, true);
24943 149 }
24944
24945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if (updatemusic)
24946 {
24947 342 playLevelMusic();
24948
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if (musicrevert)
24949 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
24950 342 }
24951 342 currcset=DMaps[currdmap].color;
24952 342 dointro();
24953 }
24954 342 break;
24955
24956 case wtWHISTLE: // whistle warp
24957 {
24958 66 scrolling_map = currmap;
24959 66 currmap = DMaps[wdmap].map;
24960 66 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
24961 66 reset_hookshot();
24962 66 currdmap=wdmap;
24963 66 dlevel=DMaps[currdmap].level;
24964 66 lighting(false, true);
24965 66 init_dmap();
24966
24967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if (updatemusic)
24968 {
24969 66 playLevelMusic();
24970
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if (musicrevert)
24971 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
24972 66 }
24973 66 currcset=DMaps[currdmap].color;
24974 66 dointro();
24975 66 action=inwind; FFCore.setHeroAction(inwind);
24976 int32_t wry;
24977
24978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_qr(qr_NOARRIVALPOINT))
24979 wry=tmpscr->warpreturny[0];
24980 66 else wry=tmpscr->warparrivaly;
24981
24982 int32_t wrx;
24983
24984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(get_qr(qr_NOARRIVALPOINT))
24985 wrx=tmpscr->warpreturnx[0];
24986 66 else wrx=tmpscr->warparrivalx;
24987
24988
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 66 times.
✓ Branch 10 taken 66 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 66 times.
✗ Branch 13 not taken.
132 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
24989
2/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
66 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
24990 66 whirlwind=255;
24991 66 whistleitem=-1;
24992 }
24993 66 break;
24994
24995 case wtIWARP:
24996 case wtIWARPBLK:
24997 case wtIWARPOPEN:
24998 case wtIWARPZAP:
24999 case wtIWARPWAVE: // insta-warps
25000 {
25001 1168 bool old_192 = false;
25002
1/2
✓ Branch 0 taken 1168 times.
✗ Branch 1 not taken.
1168 if (get_qr(qr_192b163_WARP))
25003 {
25004 if ( wtype == wtIWARPWAVE )
25005 {
25006 wtype = wtIWARPWAVE;
25007 old_192 = true;
25008 }
25009 if ( old_192 )
25010 {
25011 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
25012 didpit=false;
25013 update_subscreens();
25014 warp_sound = 0;
25015 is_warping = false;
25016 return false;
25017 }
25018 }
25019 //for determining whether to exit cave
25020 1168 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25021 1168 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25022 1168 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25023
25024
8/8
✓ Branch 0 taken 1051 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 1025 times.
✓ Branch 4 taken 1051 times.
✓ Branch 5 taken 26 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1033 times.
2271 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
25025
8/8
✓ Branch 0 taken 1036 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1013 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 1036 times.
✓ Branch 6 taken 1019 times.
✓ Branch 7 taken 17 times.
1051 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
25026
25027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1060 times.
1290 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
25028 {
25029 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
25030 1060 bool wasswimming = (action == swimming);
25031 1060 int32_t olddiveclk = diveclk;
25032 1060 ALLOFF();
25033
25034
2/2
✓ Branch 0 taken 1036 times.
✓ Branch 1 taken 24 times.
1060 if(wasswimming)
25035 {
25036 24 Hero.SetSwim();
25037 24 diveclk = olddiveclk;
25038 24 }
25039
25040 1060 kill_sfx();
25041 1060 }
25042 //play sound
25043
2/2
✓ Branch 0 taken 1018 times.
✓ Branch 1 taken 42 times.
1060 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25044
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 959 times.
1060 if(wtype==wtIWARPZAP)
25045 {
25046 101 zapout();
25047 101 }
25048
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 894 times.
959 else if(wtype==wtIWARPWAVE)
25049 {
25050 //only draw Hero if he's not in a cave -DD
25051 65 wavyout(!cavewarp);
25052 65 }
25053
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 245 times.
894 else if(wtype!=wtIWARP)
25054 {
25055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 bool b2 = COOLSCROLL&&cavewarp;
25056 245 blackscr(30,b2?false:true);
25057 245 }
25058
25059 1060 int32_t c = DMaps[currdmap].color;
25060 1060 bool changedlevel = false;
25061 1060 bool changeddmap = false;
25062
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 597 times.
1060 if(currdmap != wdmap)
25063 {
25064 597 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25065 597 changeddmap = true;
25066 597 }
25067
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 371 times.
1060 if(dlevel != DMaps[wdmap].level)
25068 {
25069 371 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25070 371 changedlevel = true;
25071 371 }
25072 1060 dlevel = DMaps[wdmap].level;
25073 1060 currdmap = wdmap;
25074
2/2
✓ Branch 0 taken 463 times.
✓ Branch 1 taken 597 times.
1060 if(changeddmap)
25075 {
25076 597 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25077 597 }
25078
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 371 times.
1060 if(changedlevel)
25079 {
25080 371 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25081 371 }
25082
25083 1060 currmap = DMaps[currdmap].map;
25084 1060 init_dmap();
25085 1060 update_subscreens(wdmap);
25086
25087 1060 ringcolor(false);
25088
25089
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 374 times.
1060 if(DMaps[currdmap].color != c)
25090 374 loadlvlpal(DMaps[currdmap].color);
25091
25092 1060 homescr = currscr = wscr + DMaps[currdmap].xoff;
25093
25094 1060 lightingInstant(); // Also sets naturaldark
25095
25096 1060 loadscr(0,currdmap,currscr,-1,overlay);
25097
25098 1060 x = tmpscr->warpreturnx[wrindex];
25099 1060 y = tmpscr->warpreturny[wrindex];
25100
25101
2/2
✓ Branch 0 taken 569 times.
✓ Branch 1 taken 491 times.
1060 if(didpit)
25102 {
25103 491 didpit=false;
25104 491 x=pitx;
25105 491 y=pity;
25106 491 }
25107
25108 1060 type1 = combobuf[MAPCOMBO(x,y-16)].type;
25109 1060 type2 = combobuf[MAPCOMBO(x,y)].type;
25110 1060 type3 = combobuf[MAPCOMBO(x,y+16)].type;
25111
25112
2/2
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 73 times.
1060 if(x==0) dir=right;
25113
25114
2/2
✓ Branch 0 taken 1056 times.
✓ Branch 1 taken 4 times.
1060 if(x==240) dir=left;
25115
25116
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 30 times.
1060 if(y==0) dir=down;
25117
25118
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 40 times.
1060 if(y==160) dir=up;
25119
25120 1060 markBmap(dir^1);
25121
25122 1060 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
25123
25124
10/16
✓ Branch 0 taken 1041 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 19 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 19 times.
✓ Branch 15 taken 1041 times.
1079 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
25125 {
25126 19 hopclk=0xFF;
25127 19 SetSwim();
25128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (!IsSideSwim()) attackclk = charging = spins = 0;
25129 19 }
25130 else
25131 {
25132 1041 action = none; FFCore.setHeroAction(none);
25133 }
25134 //preloaded freeform combos
25135 1060 ffscript_engine(true);
25136
25137 1060 putscr(scrollbuf,0,0,tmpscr);
25138 1060 putscrdoors(scrollbuf,0,0,tmpscr);
25139
25140
10/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 1025 times.
✓ Branch 4 taken 1055 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 1027 times.
✓ Branch 8 taken 62 times.
✓ Branch 9 taken 90 times.
1060 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25141 {
25142 127 reset_pal_cycling();
25143 127 putscr(scrollbuf,0,0,tmpscr);
25144 127 putscrdoors(scrollbuf,0,0,tmpscr);
25145 127 walkup(COOLSCROLL);
25146 127 }
25147
9/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1055 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 1029 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 26 times.
1117 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25148 {
25149 124 reset_pal_cycling();
25150 124 putscr(scrollbuf,0,0,tmpscr);
25151 124 putscrdoors(scrollbuf,0,0,tmpscr);
25152 124 walkdown2(COOLSCROLL);
25153 124 }
25154
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 954 times.
1055 else if(wtype==wtIWARPZAP)
25155 {
25156 101 zapin();
25157 101 }
25158
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 889 times.
954 else if(wtype==wtIWARPWAVE)
25159 {
25160 65 wavyin();
25161 65 }
25162
2/2
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 82 times.
889 else if(wtype==wtIWARPOPEN)
25163 {
25164 82 openscreen();
25165 82 }
25166
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(reposition_sword_postwarp)
25167 {
25168 weapon *swd=NULL;
25169 for(int32_t i=0; i<Lwpns.Count(); i++)
25170 {
25171 swd = (weapon*)Lwpns.spr(i);
25172
25173 if(swd->id == (attack==wSword ? wSword : wWand))
25174 {
25175 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25176 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25177 positionSword(swd,item_id);
25178 break;
25179 }
25180 }
25181 }
25182 1182 show_subscreen_life=true;
25183 1182 show_subscreen_numbers=true;
25184
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1060 times.
1182 if (updatemusic)
25185 {
25186 1060 playLevelMusic();
25187
1/2
✓ Branch 0 taken 1060 times.
✗ Branch 1 not taken.
1060 if (musicrevert)
25188 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
25189 1060 }
25190 1182 currcset=DMaps[currdmap].color;
25191 1182 dointro();
25192 1182 set_respawn_point();
25193 1182 trySideviewLadder();
25194 }
25195 1182 break;
25196
25197
25198 case wtNOWARP:
25199 {
25200 bool old_192 = false;
25201 if (get_qr(qr_192b163_WARP))
25202 {
25203 wtype = wtIWARPWAVE;
25204 old_192 = true;
25205 }
25206 if ( old_192 )
25207 {
25208 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
25209 //for determining whether to exit cave
25210 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25211 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25212 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25213
25214 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
25215 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
25216
25217 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
25218 {
25219 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
25220 bool wasswimming = (action == swimming);
25221 int32_t olddiveclk = diveclk;
25222 ALLOFF();
25223
25224 if(wasswimming)
25225 {
25226 Hero.SetSwim();
25227 diveclk = olddiveclk;
25228 }
25229
25230 kill_sfx();
25231 }
25232 //play sound
25233 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
25234 if(wtype==wtIWARPZAP)
25235 {
25236 zapout();
25237 }
25238 else if(wtype==wtIWARPWAVE)
25239 {
25240 //only draw Hero if he's not in a cave -DD
25241 wavyout(!cavewarp);
25242 }
25243 else if(wtype!=wtIWARP)
25244 {
25245 bool b2 = COOLSCROLL&&cavewarp;
25246 blackscr(30,b2?false:true);
25247 }
25248
25249 int32_t c = DMaps[currdmap].color;
25250 bool changedlevel = false;
25251 bool changeddmap = false;
25252 if(currdmap != wdmap)
25253 {
25254 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25255 changeddmap = true;
25256 }
25257 if(dlevel != DMaps[wdmap].level)
25258 {
25259 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25260 changedlevel = true;
25261 }
25262 dlevel = DMaps[wdmap].level;
25263 currdmap = wdmap;
25264 if(changeddmap)
25265 {
25266 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25267 }
25268 if(changedlevel)
25269 {
25270 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25271 }
25272 currmap = DMaps[currdmap].map;
25273 init_dmap();
25274 update_subscreens(wdmap);
25275
25276 ringcolor(false);
25277
25278 if(DMaps[currdmap].color != c)
25279 loadlvlpal(DMaps[currdmap].color);
25280
25281 homescr = currscr = wscr + DMaps[currdmap].xoff;
25282
25283 lightingInstant(); // Also sets naturaldark
25284
25285 loadscr(0,currdmap,currscr,-1,overlay);
25286
25287 x = tmpscr->warpreturnx[wrindex];
25288 y = tmpscr->warpreturny[wrindex];
25289
25290 if(didpit)
25291 {
25292 didpit=false;
25293 x=pitx;
25294 y=pity;
25295 }
25296
25297 type1 = combobuf[MAPCOMBO(x,y-16)].type;
25298 type2 = combobuf[MAPCOMBO(x,y)].type;
25299 type3 = combobuf[MAPCOMBO(x,y+16)].type;
25300
25301 if(x==0) dir=right;
25302
25303 if(x==240) dir=left;
25304
25305 if(y==0) dir=down;
25306
25307 if(y==160) dir=up;
25308
25309 markBmap(dir^1);
25310
25311 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
25312 {
25313 hopclk=0xFF;
25314 SetSwim();
25315 if (!IsSideSwim()) attackclk = charging = spins = 0;
25316 }
25317 else
25318 {
25319 action = none;
25320 FFCore.setHeroAction(none);
25321 }
25322 //preloaded freeform combos
25323 ffscript_engine(true);
25324
25325 putscr(scrollbuf,0,0,tmpscr);
25326 putscrdoors(scrollbuf,0,0,tmpscr);
25327
25328 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25329 {
25330 reset_pal_cycling();
25331 putscr(scrollbuf,0,0,tmpscr);
25332 putscrdoors(scrollbuf,0,0,tmpscr);
25333 walkup(COOLSCROLL);
25334 }
25335 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25336 {
25337 reset_pal_cycling();
25338 putscr(scrollbuf,0,0,tmpscr);
25339 putscrdoors(scrollbuf,0,0,tmpscr);
25340 walkdown2(COOLSCROLL);
25341 }
25342 else if(wtype==wtIWARPZAP)
25343 {
25344 zapin();
25345 }
25346 else if(wtype==wtIWARPWAVE)
25347 {
25348 wavyin();
25349 }
25350 else if(wtype==wtIWARPOPEN)
25351 {
25352 openscreen();
25353 }
25354 if(reposition_sword_postwarp)
25355 {
25356 weapon *swd=NULL;
25357 for(int32_t i=0; i<Lwpns.Count(); i++)
25358 {
25359 swd = (weapon*)Lwpns.spr(i);
25360
25361 if(swd->id == (attack==wSword ? wSword : wWand))
25362 {
25363 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25364 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25365 positionSword(swd,item_id);
25366 break;
25367 }
25368 }
25369 }
25370 show_subscreen_life=true;
25371 show_subscreen_numbers=true;
25372 playLevelMusic();
25373 currcset=DMaps[currdmap].color;
25374 dointro();
25375 set_respawn_point();
25376 trySideviewLadder();
25377 break;
25378 }
25379 else
25380 {
25381 if(reposition_sword_postwarp)
25382 {
25383 weapon *swd=NULL;
25384 for(int32_t i=0; i<Lwpns.Count(); i++)
25385 {
25386 swd = (weapon*)Lwpns.spr(i);
25387
25388 if(swd->id == (attack==wSword ? wSword : wWand))
25389 {
25390 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25391 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25392 positionSword(swd,item_id);
25393 break;
25394 }
25395 }
25396 }
25397 didpit=false;
25398 update_subscreens();
25399 warp_sound = 0;
25400 is_warping = false;
25401 return false;
25402 }
25403 }
25404 default:
25405 didpit=false;
25406 update_subscreens();
25407 warp_sound = 0;
25408 is_warping = false;
25409 if(reposition_sword_postwarp)
25410 {
25411 weapon *swd=NULL;
25412 for(int32_t i=0; i<Lwpns.Count(); i++)
25413 {
25414 swd = (weapon*)Lwpns.spr(i);
25415
25416 if(swd->id == (attack==wSword ? wSword : wWand))
25417 {
25418 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25419 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25420 positionSword(swd,item_id);
25421 break;
25422 }
25423 }
25424 }
25425 return false;
25426 }
25427
25428
25429
25430 // Stop Hero from drowning!
25431
5/6
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 2746 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 2618 times.
2874 if(action==drowning || action==lavadrowning || action==sidedrowning)
25432 {
25433 256 drownclk=0;
25434 256 drownclk=0;
25435 256 action=none; FFCore.setHeroAction(none);
25436 256 }
25437
25438 2618 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
25439 // But keep him swimming if he ought to be!
25440 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
25441
10/12
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 2706 times.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 33 times.
✓ Branch 10 taken 2840 times.
✓ Branch 11 taken 22 times.
2651 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_qr(qr_DROWN))
25442 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
25443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
34 && (action!=inwind))
25444 {
25445 22 hopclk=0xFF;
25446 22 SetSwim();
25447 22 }
25448
25449 2862 newscr_clk=frame;
25450 2862 activated_timed_warp=false;
25451 2862 eat_buttons();
25452
25453
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 2097 times.
2862 if(wtype!=wtIWARP)
25454 2097 attackclk=0;
25455
25456 2862 didstuff=0;
25457 2862 usecounts.clear();
25458 2862 map_bkgsfx(true);
25459 2862 loadside=dir^1;
25460 2862 whistleclk=-1;
25461
25462
3/4
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 2862 times.
✗ Branch 3 not taken.
2862 if((z>0 || fakez>0) && isSideViewHero())
25463 {
25464 y-=z;
25465 y-=fakez;
25466 fakez=0;
25467 z=0;
25468 }
25469
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 2627 times.
2862 else if(!isSideViewHero())
25470 {
25471 2627 fall=0;
25472 2627 fakefall=0;
25473 2627 }
25474
25475 // If warping between top-down and sideview screens,
25476 // fix enemies that are carried over by Full Screen Warp
25477 2862 const bool tmpscr_is_sideview = isSideViewHero();
25478
25479
4/4
✓ Branch 0 taken 2629 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 2600 times.
✓ Branch 3 taken 29 times.
2862 if(!wasSideview && tmpscr_is_sideview)
25480 {
25481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<guys.Count(); i++)
25482 {
25483 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
25484 {
25485 guys.spr(i)->y -= guys.spr(i)->z;
25486 guys.spr(i)->y -= guys.spr(i)->fakez;
25487 guys.spr(i)->z = 0;
25488 guys.spr(i)->fakez = 0;
25489 }
25490
25491 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25492 guys.spr(i)->yofs += 2;
25493 }
25494 29 }
25495
4/4
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 2716 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 27 times.
2833 else if(wasSideview && !tmpscr_is_sideview)
25496 {
25497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
25498 {
25499 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
25500 guys.spr(i)->yofs -= 2;
25501 }
25502 27 }
25503
25504
6/6
✓ Branch 0 taken 1802 times.
✓ Branch 1 taken 1060 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 1523 times.
✓ Branch 4 taken 224 times.
✓ Branch 5 taken 95 times.
2862 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_qr(qr_DMAP_0_CONTINUE_BUG)))
25505 {
25506
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 922 times.
1284 if(dlevel)
25507 {
25508 int32_t wrx,wry;
25509
25510
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 267 times.
294 if(get_qr(qr_NOARRIVALPOINT))
25511 {
25512 27 wrx=tmpscr->warpreturnx[0];
25513 27 wry=tmpscr->warpreturny[0];
25514 27 }
25515 else
25516 {
25517 267 wrx=tmpscr->warparrivalx;
25518 267 wry=tmpscr->warparrivaly;
25519 }
25520
25521
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
294 if((wtype == wtEXIT)
25522
7/10
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 209 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
294 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))))
25523 {
25524
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
81 if(!(wtype==wtSCROLL)||!(get_qr(qr_NOSCROLLCONTINUE)))
25525 {
25526 81 game->set_continue_scrn(homescr);
25527 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
25528 81 }
25529 else if(currdmap != game->get_continue_dmap())
25530 {
25531 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25532 }
25533 81 }
25534 else
25535 {
25536
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 27 times.
213 if(currdmap != game->get_continue_dmap())
25537 {
25538 27 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25539 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
25540 27 }
25541 }
25542 294 }
25543 else
25544 {
25545 922 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
25546 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
25547 }
25548
25549 1216 game->set_continue_dmap(currdmap);
25550 1216 lastentrance_dmap = currdmap;
25551 1216 lastentrance = game->get_continue_scrn();
25552 //Z_message("continue_map = %d\n",game->get_continue_dmap());
25553 1216 }
25554
25555
1/2
✓ Branch 0 taken 2834 times.
✗ Branch 1 not taken.
2834 if(tmpscr->flags4&fAUTOSAVE)
25556 {
25557 save_game(true,0);
25558 }
25559
25560
2/2
✓ Branch 0 taken 2822 times.
✓ Branch 1 taken 12 times.
2834 if(tmpscr->flags6&fCONTINUEHERE)
25561 {
25562 12 lastentrance_dmap = currdmap;
25563 12 lastentrance = homescr;
25564 12 }
25565
25566 2834 update_subscreens();
25567 2834 verifyBothWeapons();
25568
25569
2/2
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 450 times.
2834 if(wtype==wtCAVE)
25570 {
25571
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 111 times.
450 if(DMaps[currdmap].flags&dmfGUYCAVES)
25572 678 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
25573 339 (char *)moduledata.roomtype_names[tmpscr[1].room]);
25574 else
25575 111 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
25576 450 }
25577 4768 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
25578
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 2068 times.
4452 wtype==wtPASS ? "Passageway" :
25579
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1468 times.
3536 wtype==wtEXIT ? "Entrance/Exit" :
25580
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1126 times.
1468 wtype==wtSCROLL ? "Scrolling Warp" :
25581 1126 wtype==wtWHISTLE ? "Whistle Warp" :
25582 "Insta-Warp");
25583
25584 2834 eventlog_mapflags();
25585
1/2
✓ Branch 0 taken 2834 times.
✗ Branch 1 not taken.
2834 if(reposition_sword_postwarp)
25586 {
25587 weapon *swd=NULL;
25588 for(int32_t i=0; i<Lwpns.Count(); i++)
25589 {
25590 swd = (weapon*)Lwpns.spr(i);
25591
25592 if(swd->id == (attack==wSword ? wSword : wWand))
25593 {
25594 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25595 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
25596 positionSword(swd,item_id);
25597 break;
25598 }
25599 }
25600 }
25601 2834 FFCore.clear_combo_scripts();
25602
4/4
✓ Branch 0 taken 1106 times.
✓ Branch 1 taken 1728 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 92 times.
2834 if (!intradmap || get_qr(qr_WARPS_RESTART_DMAPSCRIPT))
25603 {
25604 2742 FFScript::deallocateAllArrays(ScriptType::DMap, olddmap);
25605 2742 FFCore.initZScriptDMapScripts();
25606 2742 FFCore.initZScriptActiveSubscreenScript();
25607
1/2
✓ Branch 0 taken 2742 times.
✗ Branch 1 not taken.
2742 if(refresh_dmap_scrollscript)
25608 {
25609 run_scrolling_script_int(false); //Pre-waitdraw
25610 refresh_dmap_scrollscript = false;
25611 }
25612 2742 }
25613 2834 is_warping = false;
25614
1/2
✓ Branch 0 taken 2834 times.
✗ Branch 1 not taken.
2834 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
25615 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
25616 2834 return true;
25617 2834 }
25618
25619 289 void HeroClass::exitcave()
25620 {
25621 289 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
25622 289 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
25623
25624 289 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25625 289 currscr=homescr;
25626 289 loadscr(0,currdmap,currscr,255,false); // bogus direction
25627 289 x = tmpscr->warpreturnx[0];
25628 289 y = tmpscr->warpreturny[0];
25629
25630
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if(didpit)
25631 {
25632 didpit=false;
25633 x=pitx;
25634 y=pity;
25635 }
25636
25637
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 15 times.
289 if(x+y == 0)
25638 15 x = y = 80;
25639
25640 289 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
25641 289 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
25642 289 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
25643
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 266 times.
577 bool b = COOLSCROLL &&
25644
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
266 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
25645
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 191 times.
191 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
25646
4/4
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 173 times.
191 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
25647
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 173 times.
✓ Branch 3 taken 5 times.
173 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
25648 311 ALLOFF();
25649 311 blackscr(30,b?false:true);
25650 311 ringcolor(false);
25651 311 loadlvlpal(DMaps[currdmap].color);
25652 311 lighting(false, true);
25653
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
311 if (updatemusic || !musicnocut)
25654 315 music_stop();
25655 327 kill_sfx();
25656 327 putscr(scrollbuf,0,0,tmpscr);
25657 327 putscrdoors(scrollbuf,0,0,tmpscr);
25658
25659
10/10
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 211 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 206 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
327 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
25660 {
25661 104 walkup(COOLSCROLL);
25662 104 }
25663
9/10
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 193 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 188 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
213 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
25664 {
25665 22 walkdown2(COOLSCROLL);
25666 22 }
25667
25668 315 show_subscreen_life=true;
25669 315 show_subscreen_numbers=true;
25670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
315 if (updatemusic || !musicnocut)
25671 315 playLevelMusic();
25672 315 currcset=DMaps[currdmap].color;
25673 315 dointro();
25674 315 newscr_clk=frame;
25675 315 activated_timed_warp=false;
25676 315 dir=down;
25677 315 set_respawn_point();
25678 315 eat_buttons();
25679 315 didstuff=0;
25680 315 usecounts.clear();
25681 315 map_bkgsfx(true);
25682 315 loadside=dir^1;
25683 315 }
25684
25685
25686 5921 void HeroClass::stepforward(int32_t steps, bool adjust)
25687 {
25688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5921 times.
5921 if ( FFCore.nostepforward ) return;
25689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5921 times.
5921 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
25690 5921 zfix tx=x; //temp x
25691 5921 zfix ty=y; //temp y
25692 5921 zfix tstep(0); //temp single step distance
25693 5921 zfix s(0); //calculated step distance for all steps
25694 5921 z3step=2;
25695 5921 int32_t sh=shiftdir;
25696 5921 shiftdir=-1;
25697
25698
2/2
✓ Branch 0 taken 101569 times.
✓ Branch 1 taken 5921 times.
107490 for(int32_t i=steps; i>0; --i)
25699 {
25700
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 101558 times.
101569 if(diagonalMovement)
25701 {
25702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25703 {
25704 11 tstep = 1.5;
25705 11 }
25706 else
25707 {
25708 tstep=z3step;
25709 z3step=(z3step%2)+1;
25710 }
25711 11 }
25712 else
25713 {
25714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101558 times.
101558 if(get_qr(qr_NEW_HERO_MOVEMENT))
25715 {
25716 tstep = 1.5;
25717 }
25718 else
25719 {
25720
2/2
✓ Branch 0 taken 57891 times.
✓ Branch 1 taken 43667 times.
101558 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
25721
25722
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 33010 times.
✓ Branch 2 taken 24881 times.
✓ Branch 3 taken 19456 times.
✓ Branch 4 taken 24211 times.
101558 switch(dir)
25723 {
25724 case up:
25725 33010 ty-=tstep;
25726 33010 break;
25727
25728 case down:
25729 24881 ty+=tstep;
25730 24881 break;
25731
25732 case left:
25733 19456 tx-=tstep;
25734 19456 break;
25735
25736 case right:
25737 24211 tx+=tstep;
25738 24211 break;
25739 }
25740 }
25741 }
25742
25743 101569 s+=tstep;
25744 101569 }
25745
25746 5921 z3step=2;
25747
25748 5921 x = x.getInt();
25749 5921 y = y.getInt();
25750
2/2
✓ Branch 0 taken 107394 times.
✓ Branch 1 taken 5921 times.
113315 while(s>=0)
25751 {
25752
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 107382 times.
107394 if(diagonalMovement)
25753 {
25754
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25755 {
25756 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25757 {
25758 walkable = false;
25759 shiftdir = -1;
25760 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25761 switch(tdir)
25762 {
25763 case left:
25764 --x;
25765 break;
25766 case right:
25767 ++x;
25768 break;
25769 case up:
25770 --y;
25771 break;
25772 case down:
25773 ++y;
25774 break;
25775 }
25776 }
25777 else
25778 {
25779 walkable=false;
25780 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25781 moveOld2(dir, 150);
25782 }
25783 }
25784 else
25785 {
25786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25787 {
25788 12 s-=1.5;
25789 12 }
25790 else
25791 {
25792 s-=z3step;
25793 }
25794 12 walkable=true;
25795 12 moveOld2(dir, 150);
25796 }
25797
25798 12 shiftdir=-1;
25799 12 }
25800 else
25801 {
25802
3/6
✓ Branch 0 taken 61293 times.
✓ Branch 1 taken 46089 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107382 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
107382 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
25803 {
25804 walkable=false;
25805 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
25806 switch(tdir)
25807 {
25808 case left:
25809 --x;
25810 break;
25811 case right:
25812 ++x;
25813 break;
25814 case up:
25815 --y;
25816 break;
25817 case down:
25818 ++y;
25819 break;
25820 }
25821 }
25822 else
25823 {
25824
2/4
✓ Branch 0 taken 107382 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 107382 times.
107382 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
25825 {
25826 s-=1.5;
25827 }
25828
2/2
✓ Branch 0 taken 61293 times.
✓ Branch 1 taken 46089 times.
107382 else if(dir<left)
25829 {
25830 61293 s-=lsteps[y.getInt()&7];
25831 61293 }
25832 else
25833 {
25834 46089 s-=lsteps[x.getInt()&7];
25835 }
25836
25837 107382 moveOld2(dir, 150);
25838 }
25839 }
25840
25841
2/2
✓ Branch 0 taken 101473 times.
✓ Branch 1 taken 5921 times.
107394 if(s<0)
25842 {
25843 // Not quite sure how this is actually supposed to work.
25844 // There have to be two cases for each direction or Hero
25845 // either walks too far onto the screen or may get stuck
25846 // going through walk-through walls.
25847
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2203 times.
✓ Branch 2 taken 1294 times.
✓ Branch 3 taken 1058 times.
✓ Branch 4 taken 1366 times.
5921 switch(dir)
25848 {
25849 case up:
25850
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 2067 times.
2203 if(y<8) // Leaving the screen
25851 136 y+=s;
25852 else // Entering the screen
25853 2067 y-=s;
25854
25855 2203 break;
25856
25857 case down:
25858
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 1179 times.
1294 if(y>152)
25859 115 y-=s;
25860 else
25861 1179 y+=s;
25862
25863 1294 break;
25864
25865 case left:
25866
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 954 times.
1058 if(x<8)
25867 104 x+=s;
25868 else
25869 954 x-=s;
25870
25871 1058 break;
25872
25873 case right:
25874
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 1247 times.
1366 if(x>=232)
25875 119 x-=s;
25876 else
25877 1247 x+=s;
25878
25879 1366 break;
25880 }
25881 5921 }
25882
25883
25884 107394 draw_screen(tmpscr);
25885
1/2
✓ Branch 0 taken 107394 times.
✗ Branch 1 not taken.
107394 if (canSideviewLadder()) setOnSideviewLadder(true);
25886 107394 advanceframe(true);
25887
25888
1/2
✓ Branch 0 taken 107394 times.
✗ Branch 1 not taken.
107394 if(Quit)
25889 return;
25890 }
25891
4/4
✓ Branch 0 taken 4555 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 1294 times.
✓ Branch 3 taken 3261 times.
5921 if(dir==right||dir==down)
25892 {
25893 2660 x=int32_t(x);
25894 2660 y=int32_t(y);
25895 2660 }
25896 else
25897 {
25898 3261 x = x.getInt();
25899 3261 y = y.getInt();
25900 }
25901 5921 set_respawn_point();
25902 5921 draw_screen(tmpscr);
25903 5921 eat_buttons();
25904 5921 shiftdir=sh;
25905 5921 }
25906
25907 233 void HeroClass::walkdown(bool opening) //entering cave
25908 {
25909
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 203 times.
233 if(opening)
25910 {
25911 203 close_black_opening(x+8, y+8+playing_field_offset, false);
25912 203 }
25913
25914 233 hclk=0;
25915 233 stop_item_sfx(itype_brang);
25916 233 sfx(WAV_STAIRS,pan(x.getInt()));
25917 233 clk=0;
25918 // int32_t cmby=(y.getInt()&0xF0)+16;
25919 // Fix Hero's position to the grid
25920 233 y=y.getInt()&0xF0;
25921 233 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
25922 233 attack=wNone;
25923 233 attackid=-1;
25924 233 reset_swordcharge();
25925 233 climb_cover_x=x.getInt()&0xF0;
25926 233 climb_cover_y=(y.getInt()&0xF0)+16;
25927
25928 233 guys.clear();
25929 233 chainlinks.clear();
25930 233 Lwpns.clear();
25931 233 Ewpns.clear();
25932 233 items.clear();
25933
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 14912 times.
15145 for(int32_t i=0; i<64; i++)
25934 {
25935 14912 herostep();
25936
25937
2/4
✓ Branch 0 taken 14912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14912 times.
14912 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25938 hero_count=(hero_count+1)%16;
25939
25940
2/2
✓ Branch 0 taken 11184 times.
✓ Branch 1 taken 3728 times.
14912 if((i&3)==3)
25941 3728 ++y;
25942
25943 14912 draw_screen(tmpscr);
25944 14912 advanceframe(true);
25945
25946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14912 times.
14912 if(Quit)
25947 break;
25948 14912 }
25949
25950 233 action=none; FFCore.setHeroAction(none);
25951 233 }
25952
25953 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
25954 {
25955 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
25956
25957
25958 // Fix Hero's position to the grid
25959 21 y=y.getInt()&0xF0;
25960
25961
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
25962 y -= 16;
25963
25964 21 climb_cover_x=x.getInt()&0xF0;
25965 21 climb_cover_y=y.getInt()&0xF0;
25966
25967 21 dir=down;
25968 21 z=fakez=fall=fakefall=0;
25969
25970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
25971 {
25972 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
25973 21 }
25974
25975 21 hclk=0;
25976 21 stop_item_sfx(itype_brang);
25977 21 sfx(WAV_STAIRS,pan(x.getInt()));
25978 21 clk=0;
25979 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
25980 21 attack=wNone;
25981 21 attackid=-1;
25982 21 reset_swordcharge();
25983
25984 21 guys.clear();
25985 21 chainlinks.clear();
25986 21 Lwpns.clear();
25987 21 Ewpns.clear();
25988 21 items.clear();
25989
25990
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
25991 {
25992 1344 herostep();
25993
25994
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
25995 hero_count=(hero_count+1)%16;
25996
25997
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
25998 336 ++y;
25999
26000 1344 draw_screen(tmpscr);
26001 1344 advanceframe(true);
26002
26003
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
26004 break;
26005 1344 }
26006
26007
26008 21 action=none; FFCore.setHeroAction(none);
26009 21 }
26010
26011 200 void HeroClass::walkup(bool opening) //exiting cave
26012 {
26013 200 int32_t type = combobuf[MAPCOMBO(x,y)].type;
26014
26015
4/6
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 192 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
200 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
26016 y+=16;
26017
26018 // Fix Hero's position to the grid
26019 200 y=y.getInt()&0xF0;
26020 200 z=fakez=fall=fakefall=0;
26021
26022
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 178 times.
200 if(opening)
26023 {
26024 178 open_black_opening(x+8, y+8+playing_field_offset-16, false);
26025 178 }
26026
26027 200 hclk=0;
26028 200 stop_item_sfx(itype_brang);
26029 200 sfx(WAV_STAIRS,pan(x.getInt()));
26030 200 dir=down;
26031 200 clk=0;
26032 // int32_t cmby=y.getInt()&0xF0;
26033 200 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
26034 200 attack=wNone;
26035 200 attackid=-1;
26036 200 reset_swordcharge();
26037 200 climb_cover_x=x.getInt()&0xF0;
26038 200 climb_cover_y=y.getInt()&0xF0;
26039
26040 200 guys.clear();
26041 200 chainlinks.clear();
26042 200 Lwpns.clear();
26043 200 Ewpns.clear();
26044 200 items.clear();
26045
26046
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 12800 times.
13000 for(int32_t i=0; i<64; i++)
26047 {
26048 12800 herostep();
26049
26050
2/4
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12800 times.
12800 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
26051 hero_count=(hero_count+1)%16;
26052
26053
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 3200 times.
12800 if((i&3)==0)
26054 3200 --y;
26055
26056 12800 draw_screen(tmpscr);
26057 12800 advanceframe(true);
26058
26059
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(Quit)
26060 break;
26061 12800 }
26062 200 map_bkgsfx(true);
26063 200 loadside=dir^1;
26064 200 action=none; FFCore.setHeroAction(none);
26065 200 }
26066
26067 193 void HeroClass::walkup2(bool opening) //entering cave2
26068 {
26069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193 times.
193 if(opening)
26070 {
26071 193 close_black_opening(x+8, y+8+playing_field_offset, false);
26072 193 }
26073
26074 193 hclk=0;
26075 193 stop_item_sfx(itype_brang);
26076 193 sfx(WAV_STAIRS,pan(x.getInt()));
26077 193 dir=up;
26078 193 clk=0;
26079 // int32_t cmby=y.getInt()&0xF0;
26080 193 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
26081 193 attack=wNone;
26082 193 attackid=-1;
26083 193 reset_swordcharge();
26084 193 climb_cover_x=x.getInt()&0xF0;
26085 193 climb_cover_y=(y.getInt()&0xF0)-16;
26086
26087 193 guys.clear();
26088 193 chainlinks.clear();
26089 193 Lwpns.clear();
26090 193 Ewpns.clear();
26091 193 items.clear();
26092
26093
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 12352 times.
12545 for(int32_t i=0; i<64; i++)
26094 {
26095 12352 herostep();
26096
26097
2/4
✓ Branch 0 taken 12352 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12352 times.
12352 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
26098 hero_count=(hero_count+1)%16;
26099
26100
2/2
✓ Branch 0 taken 9264 times.
✓ Branch 1 taken 3088 times.
12352 if((i&3)==0)
26101 3088 --y;
26102
26103 12352 draw_screen(tmpscr);
26104 12352 advanceframe(true);
26105
26106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12352 times.
12352 if(Quit)
26107 break;
26108 12352 }
26109 193 map_bkgsfx(true);
26110 193 loadside=dir^1;
26111 193 action=none; FFCore.setHeroAction(none);
26112 193 }
26113
26114 325 void HeroClass::stepout() // Step out of item cellars and passageways
26115 {
26116 325 bool updatemusic = FFCore.can_dmap_change_music(currdmap);
26117 325 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
26118
26119 325 int32_t sc = specialcave; // This gets erased by ALLOFF()
26120 325 ALLOFF();
26121 325 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
26122 325 map_bkgsfx(false);
26123 325 kill_enemy_sfx();
26124 325 draw_screen(tmpscr,false);
26125 325 fade(sc>=GUYCAVE?10:11,true,false);
26126 325 blackscr(30,true);
26127 325 ringcolor(false);
26128
26129
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 183 times.
325 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
26130 {
26131 183 currdmap=stepoutdmap;
26132 183 currmap=DMaps[currdmap].map;
26133 183 dlevel=DMaps[currdmap].level;
26134
26135 //we might have just left a passage, so be sure to update the CSet record -DD
26136 183 currcset=DMaps[currdmap].color;
26137
26138 183 init_dmap();
26139 183 homescr=stepoutscr;
26140 183 }
26141
26142 325 currscr=homescr;
26143 325 loadscr(0,currdmap,currscr,255,false); // bogus direction
26144 325 draw_screen(tmpscr,false);
26145
26146
3/4
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✓ Branch 3 taken 6 times.
325 if(get_qr(qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
26147 {
26148 319 darkroom = naturaldark = false;
26149 319 fade(DMaps[currdmap].color,true,true);
26150 319 }
26151 else
26152 {
26153 6 darkroom = naturaldark = true;
26154
26155
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if(get_qr(qr_FADE))
26156 {
26157 4 interpolatedfade();
26158 4 }
26159 else
26160 {
26161 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
26162 }
26163 6 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
26164 6 si+=3*48;
26165
26166
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<16; i++)
26167 {
26168 96 RAMpal[CSET(9)+i] = _RGB(si);
26169 96 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
26170 96 si+=3;
26171 96 }
26172 }
26173
26174 325 x = tmpscr->warpreturnx[stepoutwr];
26175 325 y = tmpscr->warpreturny[stepoutwr];
26176
26177
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 if(didpit)
26178 {
26179 didpit=false;
26180 x=pitx;
26181 y=pity;
26182 }
26183
26184
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 16 times.
325 if(x+y == 0)
26185 16 x = y = 80;
26186
26187 325 dir=down;
26188
26189 325 set_respawn_point();
26190
26191 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
26192 325 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
26193
26194
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
26195 {
26196 walkup(false);
26197 }
26198
4/6
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 320 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
325 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
26199 {
26200 walkdown2(false);
26201 }
26202
26203 325 newscr_clk=frame;
26204 325 activated_timed_warp=false;
26205 325 didstuff=0;
26206 325 usecounts.clear();
26207 325 eat_buttons();
26208 325 markBmap(-1);
26209 325 map_bkgsfx(true);
26210
26211
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 27 times.
325 if(!get_qr(qr_CAVEEXITNOSTOPMUSIC))
26212 {
26213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27 if (updatemusic || !musicnocut)
26214 {
26215 27 music_stop();
26216 27 playLevelMusic();
26217 27 }
26218 27 }
26219
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 else if(get_qr(qr_SCREEN80_OWN_MUSIC))
26220 {
26221 if (updatemusic || !musicnocut)
26222 playLevelMusic();
26223 }
26224
26225 325 loadside=dir^1;
26226 325 }
26227
26228 14830 bool HeroClass::nextcombo_wf(int32_t d2)
26229 {
26230
6/8
✓ Branch 0 taken 14773 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 14521 times.
✓ Branch 3 taken 252 times.
✓ Branch 4 taken 14521 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 252 times.
✗ Branch 7 not taken.
14830 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
26231 14830 return false;
26232
26233 // assumes Hero is about to scroll screens
26234
26235 int32_t ns = nextscr(d2);
26236
26237 if(ns==0xFFFF)
26238 return false;
26239
26240 // want actual screen index, not game->maps[] index
26241 ns = (ns&127) + (ns>>7)*MAPSCRS;
26242
26243 int32_t cx = x;
26244 int32_t cy = y;
26245
26246 switch(d2)
26247 {
26248 case up:
26249 cy=160;
26250 break;
26251
26252 case down:
26253 cy=0;
26254 break;
26255
26256 case left:
26257 cx=240;
26258 break;
26259
26260 case right:
26261 cx=0;
26262 break;
26263 }
26264
26265 // check lower half of combo
26266 cy += 8;
26267
26268 // from MAPCOMBO()
26269 int32_t cmb = (cy&0xF0)+(cx>>4);
26270
26271 if(cmb>175)
26272 return true;
26273
26274 newcombo c = combobuf[TheMaps[ns].data[cmb]];
26275 bool dried = iswater_type(c.type) && DRIEDLAKE;
26276 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26277 int32_t b=1;
26278
26279 if(cx&8) b<<=2;
26280
26281 if(cy&8) b<<=1;
26282
26283 if((c.walk&b) && !dried && !swim)
26284 return true;
26285
26286 // next block (i.e. cnt==2)
26287 if(!(cx&8))
26288 {
26289 b<<=2;
26290 }
26291 else
26292 {
26293 c = combobuf[TheMaps[ns].data[++cmb]];
26294 dried = iswater_type(c.type) && DRIEDLAKE;
26295 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
26296 b=1;
26297
26298 if(cy&8)
26299 {
26300 b<<=1;
26301 }
26302 }
26303
26304 return (c.walk&b) ? !dried && !swim : false;
26305 14830 }
26306
26307 bool HeroClass::nextcombo_solid(int32_t d2)
26308 {
26309 if(toogam || currscr>=128)
26310 return false;
26311
26312 // assumes Hero is about to scroll screens
26313
26314 int32_t ns = nextscr(d2);
26315
26316 if(ns==0xFFFF)
26317 return false;
26318
26319 // want actual screen index, not game->maps[] index
26320 ns = (ns&127) + (ns>>7)*MAPSCRS;
26321 int32_t screen = (ns%MAPSCRS);
26322 int32_t map = (ns - screen) / MAPSCRS;
26323
26324 int32_t cx = x;
26325 int32_t cy = y;
26326
26327 switch(d2)
26328 {
26329 case up:
26330 cy=160;
26331 break;
26332
26333 case down:
26334 cy=0;
26335 break;
26336
26337 case left:
26338 cx=240;
26339 break;
26340
26341 case right:
26342 cx=0;
26343 break;
26344 }
26345
26346 if(d2==up) cy += 8;
26347
26348 if(d2==left||d2==right) cy+=bigHitbox?0:8;
26349
26350 int32_t initcx = cx;
26351 int32_t initcy = cy;
26352 // from MAPCOMBO()
26353
26354 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
26355 {
26356 cx = initcx;
26357 for(int32_t k=0; k<=(get_qr(qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
26358 {
26359 int32_t cmb = (cy&0xF0)+(cx>>4);
26360
26361 if(cmb>175)
26362 {
26363 return true;
26364 }
26365
26366 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL))];
26367
26368 int32_t b=1;
26369
26370 if(cx&8) b<<=2;
26371
26372 if(cy&8) b<<=1;
26373
26374 //bool bridgedetected = false;
26375
26376 int32_t walk = c.walk;
26377 if (get_qr(qr_SMARTER_SMART_SCROLL))
26378 {
26379 for (int32_t m = 0; m <= 1; m++)
26380 {
26381 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
26382 if (cmb.type == cBRIDGE)
26383 {
26384 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
26385 {
26386 int efflag = (cmb.walk & 0xF0)>>4;
26387 int newsolid = (cmb.walk & 0xF);
26388 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
26389 }
26390 else walk &= cmb.walk;
26391 }
26392 else walk |= cmb.walk;
26393 }
26394 }
26395 /*
26396 if (bridgedetected)
26397 {
26398 continue;
26399 }*/
26400
26401 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
26402 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_qr(qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
26403
26404 if((walk&b) && !swim)
26405 {
26406 return true;
26407 }
26408 }
26409
26410 /*
26411 #if 0
26412
26413 //
26414 // next block (i.e. cnt==2)
26415 if(!(cx&8))
26416 {
26417 b<<=2;
26418 }
26419 else
26420 {
26421 c = combobuf[TheMaps[ns].data[++cmb]];
26422 dried = iswater_type(c.type) && DRIEDLAKE;
26423 //swim = iswater_type(c.type) && (current_item(itype_flippers));
26424 b=1;
26425
26426 if(cy&8)
26427 {
26428 b<<=1;
26429 }
26430 }
26431
26432 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26433
26434 if((c.walk&b) && !dried && !swim)
26435 {
26436 return true;
26437 }
26438
26439 cx+=8;
26440
26441 if(cx&7)
26442 {
26443 if(!(cx&8))
26444 {
26445 b<<=2;
26446 }
26447 else
26448 {
26449 c = combobuf[TheMaps[ns].data[++cmb]];
26450 dried = iswater_type(c.type) && DRIEDLAKE;
26451 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26452 b=1;
26453
26454 if(cy&8)
26455 {
26456 b<<=1;
26457 }
26458 }
26459
26460 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
26461
26462 if((c.walk&b) && !dried && !swim)
26463 return true;
26464 }
26465
26466 #endif
26467 */
26468 }
26469
26470 return false;
26471 }
26472
26473 7262487 void HeroClass::checkscroll()
26474 {
26475 //DO NOT scroll if Hero is vibrating due to Divine Escape effect -DD
26476
2/4
✓ Branch 0 taken 7262487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7262487 times.
✗ Branch 3 not taken.
7262487 if(action == casting||action==sideswimcasting)
26477 return;
26478
26479
2/2
✓ Branch 0 taken 7248132 times.
✓ Branch 1 taken 14355 times.
7262487 if(toogam)
26480 {
26481
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14345 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
14355 if(x<0 && (currscr&15)==0) x=0;
26482
26483
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 14334 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
14355 if(y<0 && currscr<16) y=0;
26484
26485
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 14338 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
14355 if(x>240 && (currscr&15)==15) x=240;
26486
26487
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 14346 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
14355 if(y>160 && currscr>=112) y=160;
26488 14355 }
26489
26490
2/2
✓ Branch 0 taken 4034 times.
✓ Branch 1 taken 7258453 times.
7262487 if(y<0)
26491 {
26492 4034 bool doit=true;
26493 4034 y=0;
26494
26495
3/6
✓ Branch 0 taken 4034 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4034 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4034 times.
✗ Branch 5 not taken.
4034 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
26496 doit = false;
26497
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4033 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
4034 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
26498 doit = false;
26499
26500
1/2
✓ Branch 0 taken 4034 times.
✗ Branch 1 not taken.
4034 if(nextcombo_wf(up))
26501 doit=false;
26502
26503
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 4034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4034 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
26504 {
26505 if(nextcombo_solid(up))
26506 doit=false;
26507 }
26508
26509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4034 if(doit || action==inwind)
26510 {
26511
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 3709 times.
4034 if(currscr>=128)
26512 {
26513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 325 times.
325 if(specialcave >= GUYCAVE)
26514 exitcave();
26515 325 else stepout();
26516 325 }
26517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3709 times.
3709 else if(action==inwind)
26518 {
26519 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26520 {
26521 action=none; FFCore.setHeroAction(none);
26522 restart_level();
26523 }
26524 else
26525 {
26526 dowarp(2,up);
26527 }
26528 }
26529
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 3609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3709 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26530 {
26531 100 sdir=up;
26532 100 dowarp(1,(tmpscr->sidewarpindex)&3);
26533 100 }
26534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3609 times.
3609 else if(!edge_of_dmap(up))
26535 {
26536 3609 scrolling_map = currmap;
26537 3609 scrollscr(up);
26538
26539
1/2
✓ Branch 0 taken 3609 times.
✗ Branch 1 not taken.
3609 if(tmpscr->flags4&fAUTOSAVE)
26540 {
26541 save_game(true,0);
26542 }
26543
26544
2/2
✓ Branch 0 taken 3604 times.
✓ Branch 1 taken 5 times.
3609 if(tmpscr->flags6&fCONTINUEHERE)
26545 {
26546 5 lastentrance_dmap = currdmap;
26547 5 lastentrance = homescr;
26548 5 }
26549 3609 }
26550 4034 }
26551 4034 }
26552
26553
2/2
✓ Branch 0 taken 3151 times.
✓ Branch 1 taken 7259336 times.
7262487 if(y>160)
26554 {
26555 3151 bool doit=true;
26556 3151 y=160;
26557
26558
5/6
✓ Branch 0 taken 3127 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 3127 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3128 times.
✓ Branch 5 taken 23 times.
3151 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
26559 23 doit = false;
26560
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
3151 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
26561 doit = false;
26562
26563
1/2
✓ Branch 0 taken 3151 times.
✗ Branch 1 not taken.
3151 if(nextcombo_wf(down))
26564 doit=false;
26565
26566
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3151 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3151 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
26567 {
26568 if(nextcombo_solid(down))
26569 doit=false;
26570 }
26571
26572
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 3128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
3151 if(doit || action==inwind)
26573 {
26574
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 2869 times.
3128 if(currscr>=128)
26575 {
26576
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 if(specialcave >= GUYCAVE)
26577 259 exitcave();
26578 else stepout();
26579 259 }
26580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2869 times.
2869 else if(action==inwind)
26581 {
26582 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26583 {
26584 action=none; FFCore.setHeroAction(none);
26585 restart_level();
26586 }
26587 else
26588 {
26589 dowarp(2,down);
26590 }
26591 }
26592
3/6
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 2569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 300 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2869 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26593 {
26594 300 sdir=down;
26595 300 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
26596 300 }
26597
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2564 times.
2569 else if(!edge_of_dmap(down))
26598 {
26599 2564 scrolling_map = currmap;
26600 2564 scrollscr(down);
26601
26602
1/2
✓ Branch 0 taken 2564 times.
✗ Branch 1 not taken.
2564 if(tmpscr->flags4&fAUTOSAVE)
26603 {
26604 save_game(true,0);
26605 }
26606
26607
2/2
✓ Branch 0 taken 2562 times.
✓ Branch 1 taken 2 times.
2564 if(tmpscr->flags6&fCONTINUEHERE)
26608 {
26609 2 lastentrance_dmap = currdmap;
26610 2 lastentrance = homescr;
26611 2 }
26612 2564 }
26613 3128 }
26614 3151 }
26615
26616
2/2
✓ Branch 0 taken 3160 times.
✓ Branch 1 taken 7259327 times.
7262487 if(x<0)
26617 {
26618 3160 bool doit=true;
26619 3160 x=0;
26620
26621
3/6
✓ Branch 0 taken 3160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3160 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3160 times.
✗ Branch 5 not taken.
3160 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
26622 doit = false;
26623
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 3136 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
3160 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
26624 doit = false;
26625
26626
1/2
✓ Branch 0 taken 3160 times.
✗ Branch 1 not taken.
3160 if(nextcombo_wf(left))
26627 doit=false;
26628
26629
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3160 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
26630 {
26631 if(nextcombo_solid(left))
26632 doit=false;
26633 }
26634
26635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3160 if(doit || action==inwind)
26636 {
26637
1/2
✓ Branch 0 taken 3160 times.
✗ Branch 1 not taken.
3160 if(currscr>=128)
26638 {
26639 if(specialcave >= GUYCAVE)
26640 exitcave();
26641 else stepout();
26642 }
26643
26644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3160 times.
3160 if(action==inwind)
26645 {
26646 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26647 {
26648 action=none; FFCore.setHeroAction(none);
26649 restart_level();
26650 }
26651 else
26652 {
26653 dowarp(2,left);
26654 }
26655 }
26656
3/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 3043 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 117 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3160 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26657 {
26658 117 sdir=left;
26659 117 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
26660 117 }
26661
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 2931 times.
3043 else if(!edge_of_dmap(left))
26662 {
26663 2931 scrolling_map = currmap;
26664 2931 scrollscr(left);
26665
26666
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if(tmpscr->flags4&fAUTOSAVE)
26667 {
26668 save_game(true,0);
26669 }
26670
26671
2/2
✓ Branch 0 taken 2923 times.
✓ Branch 1 taken 8 times.
2931 if(tmpscr->flags6&fCONTINUEHERE)
26672 {
26673 8 lastentrance_dmap = currdmap;
26674 8 lastentrance = homescr;
26675 8 }
26676 2931 }
26677 3160 }
26678 3160 }
26679
26680
2/2
✓ Branch 0 taken 3579 times.
✓ Branch 1 taken 7258908 times.
7262487 if(x>240)
26681 {
26682 3579 bool doit=true;
26683 3579 x=240;
26684
26685
5/6
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 3566 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3566 times.
✓ Branch 5 taken 13 times.
3579 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
26686 13 doit = false;
26687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3579 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
26688 doit = false;
26689
26690
1/2
✓ Branch 0 taken 3579 times.
✗ Branch 1 not taken.
3579 if(nextcombo_wf(right))
26691 doit=false;
26692
26693
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 3579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3579 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
26694 {
26695 if(nextcombo_solid(right))
26696 doit=false;
26697 }
26698
26699
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
3579 if(doit || action==inwind)
26700 {
26701
1/2
✓ Branch 0 taken 3566 times.
✗ Branch 1 not taken.
3566 if(currscr>=128)
26702 {
26703 if(specialcave >= GUYCAVE)
26704 exitcave();
26705 else stepout();
26706 }
26707
26708
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3499 times.
3566 if(action==inwind)
26709 {
26710
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 66 times.
67 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
26711 {
26712 1 action=none; FFCore.setHeroAction(none);
26713 1 restart_level();
26714 1 }
26715 else
26716 {
26717 66 dowarp(2,right);
26718 }
26719 67 }
26720
3/6
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3373 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3499 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
26721 {
26722 126 sdir=right;
26723 126 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
26724 126 }
26725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3373 times.
3373 else if(!edge_of_dmap(right))
26726 {
26727 3373 scrolling_map = currmap;
26728 3373 scrollscr(right);
26729
26730
1/2
✓ Branch 0 taken 3373 times.
✗ Branch 1 not taken.
3373 if(tmpscr->flags4&fAUTOSAVE)
26731 {
26732 save_game(true,0);
26733 }
26734
26735
2/2
✓ Branch 0 taken 3361 times.
✓ Branch 1 taken 12 times.
3373 if(tmpscr->flags6&fCONTINUEHERE)
26736 {
26737 12 lastentrance_dmap = currdmap;
26738 12 lastentrance = homescr;
26739 12 }
26740 3373 }
26741 3566 }
26742 3579 }
26743 7262487 }
26744
26745 // assumes current direction is in lastdir[3]
26746 // compares directions with scr->path and scr->exitdir
26747 37429 bool HeroClass::checkmaze(mapscr *scr, bool sound)
26748 {
26749
2/2
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 382 times.
37429 if(!(scr->flags&fMAZE))
26750 37047 return true;
26751
26752
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 334 times.
382 if(lastdir[3]==scr->exitdir)
26753 48 return true;
26754
26755
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 48 times.
574 for(int32_t i=0; i<4; i++)
26756
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 286 times.
526 if(lastdir[i]!=scr->path[i])
26757 286 return false;
26758
26759
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 if(sound)
26760 24 sfx(scr->secretsfx);
26761
26762 48 return true;
26763 37429 }
26764
26765 24952 bool HeroClass::edge_of_dmap(int32_t side)
26766 {
26767
2/2
✓ Branch 0 taken 24785 times.
✓ Branch 1 taken 167 times.
24952 if(checkmaze(tmpscr,false)==false)
26768 167 return false;
26769
26770 // needs fixin'
26771 // should check dmap style
26772
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7113 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 5911 times.
✓ Branch 4 taken 6677 times.
24785 switch(side)
26773 {
26774 case up:
26775 7113 return currscr<16;
26776
26777 case down:
26778 5084 return currscr>=112;
26779
26780 case left:
26781
2/2
✓ Branch 0 taken 5799 times.
✓ Branch 1 taken 112 times.
5911 if((currscr&15)==0)
26782 112 return true;
26783
26784
2/2
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 2799 times.
5799 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26785 // if(dlevel)
26786 3000 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
26787
26788 2799 break;
26789
26790 case right:
26791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6677 times.
6677 if((currscr&15)==15)
26792 return true;
26793
26794
2/2
✓ Branch 0 taken 3581 times.
✓ Branch 1 taken 3096 times.
6677 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
26795 // if(dlevel)
26796 3581 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
26797
26798 3096 break;
26799 }
26800
26801 5895 return false;
26802 24952 }
26803
26804 217 bool HeroClass::lookaheadraftflag(int32_t d2)
26805 {
26806 // Helper for scrollscr that gets next combo on next screen.
26807 // Can use destscr for scrolling warps,
26808 // but assumes currmap is correct.
26809
26810 217 int32_t cx = x;
26811 217 int32_t cy = y + 8;
26812
26813 217 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26814 217 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26815 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26816 //Applying this here, too. -Z
26817
26818
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 57 times.
217 switch(d2)
26819 {
26820 case up:
26821 58 cy=160;
26822 58 break;
26823
26824 case down:
26825 49 cy=0;
26826 49 break;
26827
26828 case left:
26829 53 cx=240;
26830 53 break;
26831
26832 case right:
26833 57 cx=0;
26834 57 break;
26835 }
26836
26837 217 int32_t combo = (cy&0xF0)+(cx>>4);
26838
26839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(combo>175)
26840 return 0;
26841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
26842
26843 217 }
26844 12885 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
26845 {
26846 // Can use destscr for scrolling warps,
26847 // but assumes currmap is correct.
26848
26849 12885 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
26850 12885 int32_t cy = vbound(y + 8,0,160);
26851 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26852 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26853 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26854
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 2645 times.
✓ Branch 3 taken 3018 times.
✓ Branch 4 taken 3538 times.
12885 switch(d2)
26855 {
26856 case up:
26857 3684 cy=160;
26858 3684 break;
26859
26860 case down:
26861 2645 cy=0;
26862 2645 break;
26863
26864 case left:
26865 3018 cx=240;
26866 3018 break;
26867
26868 case right:
26869 3538 cx=0;
26870 3538 break;
26871 }
26872
26873 12885 int32_t combo = (cy&0xF0)+(cx>>4);
26874
26875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(combo>175)
26876 return 0;
26877
26878 12885 return tmpscr[0].data[combo]; // entire combo code
26879 12885 }
26880
26881 12885 int32_t HeroClass::lookaheadflag(int32_t d2)
26882 {
26883 // Helper for scrollscr that gets next combo on next screen.
26884 // Can use destscr for scrolling warps,
26885 // but assumes currmap is correct.
26886
26887 12885 int32_t cx = vbound(x,0,240);
26888 12885 int32_t cy = vbound(y + 8,0,160);
26889
26890 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26891 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
26892 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
26893 //Applying this here, too. -Z
26894
26895
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 2645 times.
✓ Branch 3 taken 3018 times.
✓ Branch 4 taken 3538 times.
12885 switch(d2)
26896 {
26897 case up:
26898 3684 cy=160;
26899 3684 break;
26900
26901 case down:
26902 2645 cy=0;
26903 2645 break;
26904
26905 case left:
26906 3018 cx=240;
26907 3018 break;
26908
26909 case right:
26910 3538 cx=0;
26911 3538 break;
26912 }
26913
26914 12885 int32_t combo = (cy&0xF0)+(cx>>4);
26915
26916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(combo>175)
26917 return 0;
26918
26919
2/2
✓ Branch 0 taken 12488 times.
✓ Branch 1 taken 397 times.
12885 if(!tmpscr[0].sflag[combo])
26920 {
26921 12488 return combobuf[tmpscr[0].data[combo]].flag; // flag
26922 }
26923
26924 397 return tmpscr[0].sflag[combo]; // flag
26925 12885 }
26926
26927 1611003 void HeroClass::run_scrolling_script_int(bool waitdraw)
26928 {
26929
2/2
✓ Branch 0 taken 805386 times.
✓ Branch 1 taken 805617 times.
1611003 if(waitdraw)
26930 {
26931
3/4
✓ Branch 0 taken 805386 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 700860 times.
✓ Branch 3 taken 104526 times.
805386 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
26932 {
26933 104526 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26934 104526 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
26935 104526 }
26936 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
26937
4/6
✓ Branch 0 taken 805386 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3513 times.
✓ Branch 3 taken 801873 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3513 times.
805386 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26938 {
26939 3513 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
26940 3513 FFCore.waitdraw(ScriptType::Player) = false;
26941 3513 }
26942 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
26943
4/6
✓ Branch 0 taken 805386 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 805352 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
805386 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26944 {
26945 34 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
26946 34 FFCore.waitdraw(ScriptType::DMap) = false;
26947 34 }
26948 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
26949
2/6
✓ Branch 0 taken 805386 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 805386 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
805386 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26950 {
26951 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
26952 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
26953 }
26954 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
26955
4/10
✓ Branch 0 taken 805386 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202 times.
✓ Branch 3 taken 805184 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 202 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
805386 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26956 {
26957 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
26958 FFCore.waitdraw(ScriptType::Screen) = 0;
26959 }
26960 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
26961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805386 times.
805386 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
26962 {
26963 805386 FFCore.itemScriptEngineOnWaitdraw();
26964 805386 }
26965 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
26966 805386 }
26967 else
26968 {
26969
4/8
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 805411 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 206 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
805617 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26970 {
26971 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
26972 }
26973 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
26974
3/4
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 156346 times.
✓ Branch 3 taken 649271 times.
805617 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
26975 {
26976 156346 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
26977 156346 }
26978 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
26979
5/6
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 797258 times.
✓ Branch 3 taken 8359 times.
✓ Branch 4 taken 793745 times.
✓ Branch 5 taken 3513 times.
805617 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
26980 {
26981 3513 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
26982 3513 }
26983 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
26984
4/6
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805617 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 793745 times.
✓ Branch 5 taken 11872 times.
805617 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26985 {
26986 11872 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
26987 11872 }
26988 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
26989
4/6
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 805617 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 793745 times.
✓ Branch 5 taken 11872 times.
805617 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
26990 {
26991 11872 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
26992 11872 }
26993 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
26994 805617 bool old = get_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING);
26995
3/4
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5584 times.
✓ Branch 3 taken 800033 times.
805617 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
26996 800033 FFCore.itemScriptEngine();
26997 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
26998
3/4
✓ Branch 0 taken 805617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 800033 times.
✓ Branch 3 taken 5584 times.
805617 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
26999 5584 FFCore.itemScriptEngine();
27000 }
27001 1611003 }
27002 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
27003 1611003 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
27004 {
27005 // For rafting (and possibly other esoteric things)
27006 // Hero's action should remain unchanged while scrolling,
27007 // but for the sake of scripts, here's an eye-watering kludge.
27008 1611003 actiontype lastaction = action;
27009 1611003 action=scrolling; FFCore.setHeroAction(scrolling);
27010
2/2
✓ Branch 0 taken 805386 times.
✓ Branch 1 taken 805617 times.
1611003 if(waitdraw)
27011 {
27012 805386 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
27013 805386 }
27014 else
27015 {
27016 805617 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
27017 }
27018 1611003 zfix storex = x, storey = y;
27019
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 405231 times.
✓ Branch 2 taken 279161 times.
✓ Branch 3 taken 425725 times.
✓ Branch 4 taken 500886 times.
1611003 switch(scrolldir)
27020 {
27021 case up:
27022
2/2
✓ Branch 0 taken 335384 times.
✓ Branch 1 taken 69847 times.
405231 if(y < 160) y = 176;
27023
4/4
✓ Branch 0 taken 59056 times.
✓ Branch 1 taken 10791 times.
✓ Branch 2 taken 23492 times.
✓ Branch 3 taken 35564 times.
69847 else if(cx > 0 && !end_frames) y = sy + 156;
27024 34283 else y = 160;
27025
27026 405231 break;
27027
27028 case down:
27029
2/2
✓ Branch 0 taken 230175 times.
✓ Branch 1 taken 48986 times.
279161 if(y > 0) y = -16;
27030
4/4
✓ Branch 0 taken 41163 times.
✓ Branch 1 taken 7823 times.
✓ Branch 2 taken 17430 times.
✓ Branch 3 taken 23733 times.
48986 else if(cx > 0 && !end_frames) y = sy - 172;
27031 25253 else y = 0;
27032
27033 279161 break;
27034
27035 case left:
27036
2/2
✓ Branch 0 taken 390882 times.
✓ Branch 1 taken 34843 times.
425725 if(x < 240) x = 256;
27037
2/2
✓ Branch 0 taken 28754 times.
✓ Branch 1 taken 6089 times.
34843 else if(cx > 0) x = sx + 236;
27038 6089 else x = 240;
27039
27040 425725 break;
27041
27042 case right:
27043
2/2
✓ Branch 0 taken 459917 times.
✓ Branch 1 taken 40969 times.
500886 if(x > 0) x = -16;
27044
2/2
✓ Branch 0 taken 33826 times.
✓ Branch 1 taken 7143 times.
40969 else if(cx > 0) x = sx - 252;
27045 7143 else x = 0;
27046
27047 500886 break;
27048 }
27049 1611003 run_scrolling_script_int(waitdraw);
27050
27051 1611003 x = storex, y = storey;
27052
27053 1611003 action=lastaction; FFCore.setHeroAction(lastaction);
27054 1611003 }
27055
27056 //Has solving the maze enabled a side warp?
27057 //Only used just before scrolling screens
27058 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
27059 // return true to abort the topmost scrollscr() call. -L
27060 12885 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
27061 {
27062
2/2
✓ Branch 0 taken 38655 times.
✓ Branch 1 taken 12885 times.
51540 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
27063
27064
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 12718 times.
12885 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
27065
27066
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12885 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
27067 {
27068 switch(scrolldir)
27069 {
27070 case up:
27071 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
27072 {
27073 lastdir[3] = 0xFF;
27074 sdir=up;
27075 dowarp(1,(tmpscr->sidewarpindex)&3);
27076 return true;
27077 }
27078
27079 break;
27080
27081 case down:
27082 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
27083 {
27084 lastdir[3] = 0xFF;
27085 sdir=down;
27086 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
27087 return true;
27088 }
27089
27090 break;
27091
27092 case left:
27093 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
27094 {
27095 lastdir[3] = 0xFF;
27096 sdir=left;
27097 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
27098 return true;
27099 }
27100
27101 break;
27102
27103 case right:
27104 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
27105 {
27106 lastdir[3] = 0xFF;
27107 sdir=right;
27108 dowarp(1,(tmpscr->sidewarpindex)&3);
27109 return true;
27110 }
27111
27112 break;
27113 }
27114 }
27115
27116 12885 return false;
27117 12885 }
27118
27119 12885 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
27120 {
27121 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
27122
2/2
✓ Branch 0 taken 1052 times.
✓ Branch 1 taken 11833 times.
12885 if(get_qr(qr_VERYFASTSCROLLING))
27123 1052 return 16;
27124
27125
2/2
✓ Branch 0 taken 10803 times.
✓ Branch 1 taken 1030 times.
11833 if(get_qr(qr_SMOOTHVERTICALSCROLLING) != 0)
27126 {
27127
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 4038 times.
10803 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
27128 }
27129 else
27130 {
27131
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1030 if(scrolldir == up || scrolldir == down)
27132 {
27133 483 return 8;
27134 }
27135 else
27136 {
27137
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
27138 }
27139 }
27140 12885 }
27141
27142 12885 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
27143 {
27144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(get_qr(qr_NOSCROLL))
27145 return 0;
27146
27147
4/4
✓ Branch 0 taken 11833 times.
✓ Branch 1 taken 1052 times.
✓ Branch 2 taken 10803 times.
✓ Branch 3 taken 1030 times.
12885 if( (get_qr(qr_VERYFASTSCROLLING) != 0) ||
27148 11833 (get_qr(qr_SMOOTHVERTICALSCROLLING) != 0) )
27149 {
27150 11855 return 1;
27151 }
27152 else
27153 {
27154
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1030 if(scrolldir == up || scrolldir == down)
27155 {
27156
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 234 times.
483 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 4 : 2;
27157 }
27158 else
27159 {
27160 547 return 1;
27161 }
27162 }
27163 12885 }
27164
27165 7038 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
27166 {
27167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7038 times.
7038 if(!get_qr(qr_NEW_DARKROOM)) return;
27168 7038 int32_t lampid = current_item_id(itype_lantern);
27169
1/2
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
7038 if(lampid < 0) return;
27170 static bool lamp_paid = false;
27171
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
27172 {
27173 lamp_paid = false;
27174 return;
27175 }
27176 7038 lamp_paid = true;
27177 7038 paymagiccost(lampid,false,true);
27178 7038 int32_t hx1 = x.getInt() - x1 + 8;
27179 7038 int32_t hy1 = y.getInt() - y1 + 8;
27180 7038 int32_t hx2 = x.getInt() - x2 + 8;
27181 7038 int32_t hy2 = y.getInt() - y2 + 8;
27182
27183 7038 itemdata& lamp = itemsbuf[lampid];
27184 7038 handle_lighting(hx1,hy1,lamp.misc1,lamp.misc2,dir,darkscr_bmp_curscr);
27185 7038 handle_lighting(hx2,hy2,lamp.misc1,lamp.misc2,dir,darkscr_bmp_scrollscr);
27186 7038 }
27187
27188 12885 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
27189 {
27190
2/4
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12885 times.
12885 if(action==freeze||action==sideswimfreeze)
27191 {
27192 return;
27193 }
27194
27195 12885 bool overlay = false;
27196
27197
2/4
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12885 times.
12885 if(scrolldir >= 0 && scrolldir <= 3)
27198 {
27199 12885 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
27200 12885 }
27201
27202
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 12477 times.
12885 if(destdmap == -1)
27203 {
27204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12477 times.
12477 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
27205
1/2
✓ Branch 0 taken 12477 times.
✗ Branch 1 not taken.
12477 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
27206 return;
27207 12477 }
27208 else
27209 {
27210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
27211
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
27212 return;
27213 }
27214
27215 12885 bool updatemusic = FFCore.can_dmap_change_music(destdmap);
27216 12885 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
27217
27218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
27219 return;
27220
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12885 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
27221 !(jumping<0 || fall!=0 || fakefall!=0) && get_qr(qr_SIDEVIEWLADDER_FACEUP);
27222
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(isForceFaceUp) dir = up;
27223 12885 kill_enemy_sfx();
27224 12885 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27225 12885 screenscrolling = true;
27226 12885 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
27227
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 2645 times.
✓ Branch 3 taken 3018 times.
✓ Branch 4 taken 3538 times.
12885 switch(scrolldir)
27228 {
27229 case up:
27230 3684 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27231 3684 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
27232 3684 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27233 3684 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27234 3684 break;
27235 case down:
27236 2645 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27237 2645 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
27238 2645 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27239 2645 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27240 2645 break;
27241 case left:
27242 3018 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
27243 3018 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27244 3018 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27245 3018 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27246 3018 break;
27247 case right:
27248 3538 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
27249 3538 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27250 3538 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27251 3538 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27252 3538 break;
27253 }
27254 12885 FFCore.clear_combo_scripts();
27255 12885 tmpscr[1] = tmpscr[0];
27256
27257 12885 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
27258
27259
2/2
✓ Branch 0 taken 77310 times.
✓ Branch 1 taken 12885 times.
90195 for(int32_t i = 0; i < 6; i++)
27260 {
27261 77310 tmpscr3[i] = tmpscr2[i];
27262 77310 }
27263
27264 12885 conveyclk = 2;
27265
27266 12885 mapscr *newscr = &tmpscr[0];
27267 12885 mapscr *oldscr = &tmpscr[1];
27268
27269 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
27270 12885 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
27271 12885 int32_t cx = 0;
27272 12885 int32_t step = get_scroll_step(scrolldir);
27273 12885 int32_t delay = get_scroll_delay(scrolldir);
27274 12885 bool end_frames = false;
27275
27276 12885 int32_t scx = get_qr(qr_FASTDNGN) ? 30 : 0;
27277
2/2
✓ Branch 0 taken 11833 times.
✓ Branch 1 taken 1052 times.
12885 if(get_qr(qr_VERYFASTSCROLLING)) //just a minor adjustment.
27278 1052 scx = 32; //for sideview very fast screolling.
27279
27280
27281 12885 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
27282 12885 actiontype lastaction = action;
27283 12885 ALLOFF(false, false);
27284 // for now, restore Hero's previous action
27285
2/2
✓ Branch 0 taken 12654 times.
✓ Branch 1 taken 231 times.
12885 if(!get_qr(qr_SCROLLING_KILLS_CHARGE))
27286 12885 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
27287 12885 action=lastaction; FFCore.setHeroAction(lastaction);
27288
27289 12885 lstep = (lstep + 6) % 12;
27290 12885 cx = scx;
27291 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
27292
3/4
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10359 times.
✓ Branch 3 taken 2526 times.
12885 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
27293 {
27294 2526 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
27295 2526 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
27296 2526 }
27297 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
27298
4/6
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 12685 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 200 times.
12885 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Player) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27299 {
27300 200 ZScriptVersion::RunScript(ScriptType::Player, SCRIPT_PLAYER_ACTIVE);
27301 200 FFCore.waitdraw(ScriptType::Player) = false;
27302 200 }
27303 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
27304
4/6
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 12883 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
12885 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27305 {
27306 2 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[currdmap].script,currdmap);
27307 2 FFCore.waitdraw(ScriptType::DMap) = false;
27308 2 }
27309 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
27310
2/6
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12885 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12885 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::PassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27311 {
27312 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script,currdmap);
27313 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
27314 }
27315 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
27316
5/8
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12882 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
12885 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && FFCore.waitdraw(ScriptType::Screen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
27317 {
27318 3 ZScriptVersion::RunScript(ScriptType::Screen, tmpscr->script);
27319 3 FFCore.waitdraw(ScriptType::Screen) = 0;
27320 3 }
27321 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
27322
27323 12885 word c = tmpscr->numFFC();
27324
2/2
✓ Branch 0 taken 405826 times.
✓ Branch 1 taken 12885 times.
418711 for ( word q = 0; q < c; ++q )
27325 {
27326
1/2
✓ Branch 0 taken 405826 times.
✗ Branch 1 not taken.
405826 if (FFCore.waitdraw(ScriptType::FFC, q))
27327 {
27328 if(tmpscr->ffcs[q].script != 0)
27329 {
27330 ZScriptVersion::RunScript(ScriptType::FFC, tmpscr->ffcs[q].script, q);
27331 FFCore.waitdraw(ScriptType::FFC, q) = false;
27332 }
27333 }
27334 405826 }
27335 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
27336 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
27337 //Waitdraw for item scripts.
27338 12885 FFCore.itemScriptEngineOnWaitdraw();
27339 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
27340 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
27341
27342 //Sprite scripts on Waitdraw
27343 12885 FFCore.eweaponScriptEngineOnWaitdraw();
27344 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
27345 12885 FFCore.itemSpriteScriptEngineOnWaitdraw();
27346 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
27347
27348 //This is no longer a do-while, as the first iteration is now slightly different. -Em
27349 12885 draw_screen(tmpscr,true,true);
27350
27351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(cx == scx)
27352 12885 rehydratelake(false);
27353
27354 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27355 12885 advanceframe(true);
27356
27357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if(Quit)
27358 {
27359 screenscrolling = false;
27360 return;
27361 }
27362
27363 12885 ++cx;
27364
2/2
✓ Branch 0 taken 111193 times.
✓ Branch 1 taken 12885 times.
124078 while(cx < 32)
27365 {
27366
1/2
✓ Branch 0 taken 111193 times.
✗ Branch 1 not taken.
111193 if(isForceFaceUp) dir = up;
27367
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 111163 times.
111193 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
27368 {
27369 30 script_drawing_commands.Clear();
27370 30 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27371 30 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
27372 30 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27373 30 }
27374 111163 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27375 111193 draw_screen(tmpscr,true,true);
27376
27377
1/2
✓ Branch 0 taken 111193 times.
✗ Branch 1 not taken.
111193 if(cx == scx)
27378 rehydratelake(false);
27379
27380 111193 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
27381 111193 advanceframe(true);
27382
27383
1/2
✓ Branch 0 taken 111193 times.
✗ Branch 1 not taken.
111193 if(Quit)
27384 {
27385 screenscrolling = false;
27386 return;
27387 }
27388
27389 111193 ++cx;
27390 }
27391 12885 script_drawing_commands.Clear();
27392 12885 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
27393
27394
27395 //clear Hero's last hits
27396 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
27397
27398
3/4
✓ Branch 0 taken 6518 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1866 times.
✓ Branch 3 taken 4501 times.
12885 switch(DMaps[currdmap].type&dmfTYPE)
27399 {
27400 case dmDNGN:
27401
1/2
✓ Branch 0 taken 4501 times.
✗ Branch 1 not taken.
4501 if(!get_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING))
27402 {
27403 markBmap(scrolldir);
27404 }
27405 4501 break;
27406 case dmOVERW: case dmBSOVERW:
27407
2/2
✓ Branch 0 taken 6440 times.
✓ Branch 1 taken 78 times.
6518 if(get_qr(qr_NO_OVERWORLD_MAP_CHARTING))
27408 6440 break;
27409 [[fallthrough]];
27410 case dmCAVE:
27411 1944 markBmap(scrolldir);
27412 1944 break;
27413 }
27414
27415
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(fixed_door)
27416 {
27417 unsetmapflag(mSECRET);
27418 fixed_door = false;
27419 }
27420 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
27421 12885 scrolling_scr = currscr;
27422
27423
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 2645 times.
✓ Branch 3 taken 3018 times.
✓ Branch 4 taken 3538 times.
12885 switch(scrolldir)
27424 {
27425 case up:
27426 {
27427
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 3609 times.
3684 if(destscr != -1)
27428 75 currscr = destscr;
27429
3/4
✓ Branch 0 taken 3559 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3559 times.
3609 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27430 3559 currscr -= 16;
27431
27432 3684 loadscr(0,destdmap,currscr,scrolldir,overlay);
27433 3684 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
27434 3684 putscr(scrollbuf,0,0,newscr);
27435 3684 putscrdoors(scrollbuf,0,0,newscr);
27436 3684 sy=176;
27437
27438
2/2
✓ Branch 0 taken 3356 times.
✓ Branch 1 taken 328 times.
3684 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
27439 328 sy+=3;
27440
27441 3684 cx=176/step;
27442 3684 FFCore.clear_combo_scripts();
27443 }
27444 3684 break;
27445
27446 case down:
27447 {
27448
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2564 times.
2645 if(destscr != -1)
27449 81 currscr = destscr;
27450
3/4
✓ Branch 0 taken 2546 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2546 times.
2564 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27451 2546 currscr += 16;
27452
27453 2645 loadscr(0,destdmap,currscr,scrolldir,overlay);
27454 2645 putscr(scrollbuf,0,176,newscr);
27455 2645 putscrdoors(scrollbuf,0,176,newscr);
27456 2645 sy = 0;
27457
27458
2/2
✓ Branch 0 taken 2490 times.
✓ Branch 1 taken 155 times.
2645 if(get_qr(qr_SMOOTHVERTICALSCROLLING) == 0)
27459 155 sy+=3;
27460
27461 2645 cx = 176 / step;
27462 2645 FFCore.clear_combo_scripts();
27463 }
27464 2645 break;
27465
27466 case left:
27467 {
27468
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 2931 times.
3018 if(destscr!=-1)
27469 87 currscr = destscr;
27470
3/4
✓ Branch 0 taken 2910 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2910 times.
2931 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27471 2910 --currscr;
27472
27473 3018 loadscr(0,destdmap,currscr,scrolldir,overlay);
27474 3018 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
27475 3018 putscr(scrollbuf,0,0,newscr);
27476 3018 putscrdoors(scrollbuf,0,0,newscr);
27477 3018 sx = 256;
27478 3018 cx = 256 / step;
27479 3018 FFCore.clear_combo_scripts();
27480 }
27481 3018 break;
27482
27483 case right:
27484 {
27485
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 3373 times.
3538 if(destscr != -1)
27486 165 currscr = destscr;
27487
3/4
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3343 times.
3373 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
27488 3343 ++currscr;
27489
27490 3538 loadscr(0,destdmap,currscr,scrolldir,overlay);
27491 3538 putscr(scrollbuf,256,0,newscr);
27492 3538 putscrdoors(scrollbuf,256,0,tmpscr);
27493 3538 sx = 0;
27494 3538 cx = 256 / step;
27495 3538 FFCore.clear_combo_scripts();
27496 }
27497 3538 break;
27498 }
27499
27500 // change Hero's state if entering water
27501 12885 int32_t ahead = lookahead(scrolldir);
27502 12885 int32_t aheadflag = lookaheadflag(scrolldir);
27503 12885 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
27504 12885 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
27505 12885 int32_t wateraheadx1 = vbound(x+4,0,240);
27506 12885 int32_t wateraheadx2 = vbound(x+11,0,240);;
27507 12885 int32_t wateraheady1 = vbound(y+9,0,160);
27508 12885 int32_t wateraheady2 = vbound(y+15,0,160);
27509 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27510 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
27511 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
27512
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3684 times.
✓ Branch 2 taken 2645 times.
✓ Branch 3 taken 3018 times.
✓ Branch 4 taken 3538 times.
12885 switch(scrolldir)
27513 {
27514 case up:
27515 3684 lookaheady=160;
27516 3684 wateraheady1=160;
27517 3684 wateraheady2=160;
27518 3684 break;
27519
27520 case down:
27521 2645 lookaheady=0;
27522 2645 wateraheady1=0;
27523 2645 wateraheady2=0;
27524 2645 break;
27525
27526 case left:
27527 3018 lookaheadx=240;
27528 3018 wateraheadx1=240;
27529 3018 wateraheadx2=240;
27530 3018 break;
27531
27532 case right:
27533 3538 lookaheadx=0;
27534 3538 wateraheadx1=0;
27535 3538 wateraheadx2=0;
27536 3538 break;
27537 }
27538
27539 12885 bool nowinwater = false;
27540
27541
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 12819 times.
12885 if(lastaction != inwind)
27542 {
27543
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 12602 times.
12819 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
27544 {
27545
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 210 times.
217 if (lookaheadraftflag(scrolldir))
27546 {
27547 210 action=rafting; FFCore.setHeroAction(rafting);
27548 210 raftclk=0;
27549 210 }
27550 217 }
27551
5/6
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 12417 times.
✓ Branch 2 taken 185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 164 times.
12602 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
27552 {
27553
9/16
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 15 times.
✗ Branch 15 not taken.
164 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
27554 {
27555 149 SetSwim();
27556 149 hopclk = 0xFF;
27557 149 nowinwater = true;
27558 149 }
27559 else
27560 {
27561 15 action=hopping; FFCore.setHeroAction(hopping);
27562 15 hopclk = 2;
27563 15 nowinwater = true;
27564 }
27565 164 }
27566
3/4
✓ Branch 0 taken 12425 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12438 times.
12438 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
27567 {
27568 action = lastaction; FFCore.setHeroAction(lastaction);
27569 }
27570 else
27571 {
27572 12438 action=none; FFCore.setHeroAction(none);
27573 }
27574 12819 }
27575
27576
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
27577
27578 // The naturaldark state can be read/set by an FFC script before
27579 // fade() or lighting() is called.
27580 12885 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
27581
27582
2/2
✓ Branch 0 taken 12653 times.
✓ Branch 1 taken 232 times.
12885 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
27583
27584
2/2
✓ Branch 0 taken 12642 times.
✓ Branch 1 taken 243 times.
12885 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
27585 //Preloaded ffc scripts
27586 12885 homescr=currscr;
27587 12885 auto olddmap = currdmap;
27588
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 12477 times.
12885 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
27589
27590 12885 currdmap = newdmap;
27591 12885 ffscript_engine(true);
27592 12885 currdmap = olddmap;
27593
27594 // There are two occasions when scrolling must be darkened:
27595 // 1) When scrolling into a dark room.
27596 // 2) When scrolling between DMaps of different colours.
27597
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 12477 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 160 times.
12885 if(destdmap != -1 && DMaps[destdmap].color != currcset)
27598 {
27599
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
27600 160 darkroom = true;
27601 160 }
27602
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 12546 times.
12725 else if(!darkroom)
27603 12546 lighting(false, false); // NES behaviour: fade to dark before scrolling
27604
27605
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 12668 times.
12885 if(action != rafting) // Is this supposed to be here?!
27606
27607 12668 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
27608
27609 12885 cx *= delay; //so we can have drawing re-done every frame,
27610 //previously it was for(0 to delay) advanceframes at end of loop
27611 12885 int32_t no_move = 0;
27612
27613 12885 currdmap = newdmap;
27614
4/4
✓ Branch 0 taken 12885 times.
✓ Branch 1 taken 805356 times.
✓ Branch 2 taken 805356 times.
✓ Branch 3 taken 12885 times.
818241 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
27615 {
27616
2/2
✓ Branch 0 taken 683907 times.
✓ Branch 1 taken 121449 times.
805356 if (replay_version_check(0, 3))
27617 {
27618 121449 replay_poll();
27619 121449 }
27620
1/2
✓ Branch 0 taken 805356 times.
✗ Branch 1 not taken.
805356 if(Quit)
27621 {
27622 screenscrolling = false;
27623 return;
27624 }
27625
27626
27627 805356 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
27628
27629
2/2
✓ Branch 0 taken 744767 times.
✓ Branch 1 taken 60589 times.
805356 if(no_move > 0)
27630 60589 no_move--;
27631
27632 //Don't want to move things on the first or last iteration, or between delays
27633
6/6
✓ Branch 0 taken 792471 times.
✓ Branch 1 taken 12885 times.
✓ Branch 2 taken 773740 times.
✓ Branch 3 taken 18731 times.
✓ Branch 4 taken 23199 times.
✓ Branch 5 taken 750541 times.
805356 if(i == 0 || cx == 0 || cx % delay != 0)
27634 54815 no_move++;
27635
27636
4/4
✓ Branch 0 taken 602779 times.
✓ Branch 1 taken 202577 times.
✓ Branch 2 taken 139553 times.
✓ Branch 3 taken 463226 times.
805356 if(scrolldir == up || scrolldir == down)
27637 {
27638
2/2
✓ Branch 0 taken 306858 times.
✓ Branch 1 taken 35272 times.
342130 if(!get_qr(qr_SMOOTHVERTICALSCROLLING))
27639 {
27640 //Add a few extra frames if on the second loop and cool scrolling is not set
27641
2/2
✓ Branch 0 taken 34789 times.
✓ Branch 1 taken 483 times.
35272 if(i == 1)
27642 {
27643 483 cx += (scrolldir == down) ? 3 : 2;
27644 483 no_move += (scrolldir == down) ? 3 : 2;
27645 483 }
27646 35272 }
27647 else
27648 {
27649 //4 frames after we've finished scrolling of being still
27650
4/4
✓ Branch 0 taken 11692 times.
✓ Branch 1 taken 295166 times.
✓ Branch 2 taken 5846 times.
✓ Branch 3 taken 5846 times.
306858 if(cx == 0 && !end_frames)
27651 {
27652 5846 cx += 4;
27653 5846 no_move += 4;
27654 5846 end_frames = true;
27655 5846 }
27656 }
27657 342130 }
27658
27659 //Move Hero and the scroll position
27660
2/2
✓ Branch 0 taken 73474 times.
✓ Branch 1 taken 731882 times.
805356 if(!no_move)
27661 {
27662
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 164933 times.
✓ Branch 2 taken 116835 times.
✓ Branch 3 taken 206795 times.
✓ Branch 4 taken 243319 times.
731882 switch(scrolldir)
27663 {
27664 case up:
27665 164933 sy -= step;
27666 164933 y += step;
27667 164933 break;
27668
27669 case down:
27670 116835 sy += step;
27671 116835 y -= step;
27672 116835 break;
27673
27674 case left:
27675 206795 sx -= step;
27676 206795 x += step;
27677 206795 break;
27678
27679 case right:
27680 243319 sx += step;
27681 243319 x -= step;
27682 243319 break;
27683 }
27684
27685 //bound Hero when me move him off the screen in the last couple of frames of scrolling
27686
2/2
✓ Branch 0 taken 14643 times.
✓ Branch 1 taken 717239 times.
731882 if(y > 160) y = 160;
27687
27688
2/2
✓ Branch 0 taken 10295 times.
✓ Branch 1 taken 721587 times.
731882 if(y < 0) y = 0;
27689
27690
2/2
✓ Branch 0 taken 12875 times.
✓ Branch 1 taken 719007 times.
731882 if(x > 240) x = 240;
27691
27692
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 716728 times.
731882 if(x < 0) x = 0;
27693
27694
4/4
✓ Branch 0 taken 731636 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 731626 times.
731882 if(ladderx > 0 || laddery > 0)
27695 {
27696 // If the ladder moves on both axes, the player can
27697 // gradually shift it by going back and forth
27698
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
27699 laddery = y.getInt();
27700 else
27701 256 ladderx = x.getInt();
27702 256 }
27703 731882 }
27704
27705 //Drawing
27706 805356 tx = sx;
27707 805356 ty = sy;
27708 805356 tx2 = sx;
27709 805356 ty2 = sy;
27710
27711
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 250395 times.
✓ Branch 2 taken 139553 times.
✓ Branch 3 taken 212831 times.
✓ Branch 4 taken 202577 times.
805356 switch(scrolldir)
27712 {
27713 case right:
27714 250395 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
27715 250395 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27716 250395 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
27717 250395 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27718 250395 tx -= 256;
27719 250395 break;
27720
27721 case down:
27722 139553 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27723 139553 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
27724 139553 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27725 139553 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
27726 139553 ty -= 176;
27727 139553 break;
27728
27729 case left:
27730 212831 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
27731 212831 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
27732 212831 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
27733 212831 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
27734 212831 tx2 -= 256;
27735 212831 break;
27736
27737 case up:
27738 202577 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
27739 202577 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
27740 202577 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
27741 202577 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
27742 202577 ty2 -= 176;
27743 202577 break;
27744 }
27745
27746 //FFScript.OnWaitdraw()
27747 805356 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
27748
27749 805356 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
27750 805356 clear_bitmap(scrollbuf);
27751 805356 clear_bitmap(framebuf);
27752 805356 clear_a5_bmp(rti_infolayer.bitmap);
27753
27754 805356 combotile_add_x = 0;
27755 805356 combotile_add_y = playing_field_offset;
27756
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 202577 times.
✓ Branch 2 taken 139553 times.
✓ Branch 3 taken 212831 times.
✓ Branch 4 taken 250395 times.
805356 switch(scrolldir)
27757 {
27758 case up:
27759
1/2
✓ Branch 0 taken 202577 times.
✗ Branch 1 not taken.
202577 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27760
27761
1/2
✓ Branch 0 taken 202577 times.
✗ Branch 1 not taken.
202577 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
27762
27763
2/2
✓ Branch 0 taken 202492 times.
✓ Branch 1 taken 85 times.
202577 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27764
27765
2/2
✓ Branch 0 taken 202492 times.
✓ Branch 1 taken 85 times.
202577 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
27766
27767 // Draw both screens' background layer primitives together, after both layers' combos.
27768 // Not ideal, but probably good enough for all realistic purposes.
27769
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 202577 times.
✓ Branch 2 taken 202577 times.
✗ Branch 3 not taken.
202577 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27770
27771
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 202492 times.
✓ Branch 2 taken 202492 times.
✓ Branch 3 taken 85 times.
202577 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27772
27773 202577 combotile_add_y -= sy;
27774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202577 times.
202577 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
27775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202577 times.
202577 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 176, oldscr);
27776 202577 break;
27777
27778 case down:
27779
1/2
✓ Branch 0 taken 139553 times.
✗ Branch 1 not taken.
139553 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
27780
27781
1/2
✓ Branch 0 taken 139553 times.
✗ Branch 1 not taken.
139553 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27782
27783
1/2
✓ Branch 0 taken 139553 times.
✗ Branch 1 not taken.
139553 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
27784
27785
1/2
✓ Branch 0 taken 139553 times.
✗ Branch 1 not taken.
139553 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27786
27787
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139553 times.
✓ Branch 2 taken 139553 times.
✗ Branch 3 not taken.
139553 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27788
27789
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139553 times.
✓ Branch 2 taken 139553 times.
✗ Branch 3 not taken.
139553 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27790
27791 139553 combotile_add_y -= sy;
27792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139553 times.
139553 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
27793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139553 times.
139553 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 176, newscr);
27794 139553 break;
27795
27796 case left:
27797
1/2
✓ Branch 0 taken 212831 times.
✗ Branch 1 not taken.
212831 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
27798
27799
1/2
✓ Branch 0 taken 212831 times.
✗ Branch 1 not taken.
212831 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
27800
27801
2/2
✓ Branch 0 taken 212741 times.
✓ Branch 1 taken 90 times.
212831 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
27802
27803
2/2
✓ Branch 0 taken 212741 times.
✓ Branch 1 taken 90 times.
212831 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
27804
27805
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 212831 times.
✓ Branch 2 taken 212831 times.
✗ Branch 3 not taken.
212831 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27806
27807
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 212741 times.
✓ Branch 2 taken 212741 times.
✓ Branch 3 taken 90 times.
212831 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27808
27809 212831 combotile_add_x -= sx;
27810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212831 times.
212831 if(lenscheck(newscr,0)) putscr(scrollbuf, 0, 0, newscr);
27811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212831 times.
212831 if(lenscheck(oldscr,0)) putscr(scrollbuf, 256, 0, oldscr);
27812 212831 break;
27813
27814 case right:
27815
1/2
✓ Branch 0 taken 250395 times.
✗ Branch 1 not taken.
250395 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
27816
27817
1/2
✓ Branch 0 taken 250395 times.
✗ Branch 1 not taken.
250395 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
27818
27819
2/2
✓ Branch 0 taken 250341 times.
✓ Branch 1 taken 54 times.
250395 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
27820
27821
2/2
✓ Branch 0 taken 250341 times.
✓ Branch 1 taken 54 times.
250395 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
27822
27823
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250395 times.
✓ Branch 2 taken 250395 times.
✗ Branch 3 not taken.
250395 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
27824
27825
4/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 250341 times.
✓ Branch 2 taken 250341 times.
✓ Branch 3 taken 54 times.
250395 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
27826
27827 250395 combotile_add_x -= sx;
27828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250395 times.
250395 if(lenscheck(oldscr,0)) putscr(scrollbuf, 0, 0, oldscr);
27829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250395 times.
250395 if(lenscheck(newscr,0)) putscr(scrollbuf, 256, 0, newscr);
27830 250395 break;
27831 }
27832
27833 805356 combotile_add_x = 0;
27834 805356 combotile_add_y = 0;
27835
27836 805356 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
27837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805356 times.
805356 if(lenscheck(newscr,0))
27838 805356 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
27839
27840 805356 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
27841 805356 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
27842
27843
2/2
✓ Branch 0 taken 748313 times.
✓ Branch 1 taken 57043 times.
805356 if(get_qr(qr_FFCSCROLL))
27844 {
27845 57043 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
27846 57043 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
27847 57043 }
27848
27849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805356 times.
805356 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
27850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805356 times.
805356 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
27851
27852 //push blocks
27853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 805356 times.
805356 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
27854 {
27855 805356 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
27856 805356 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
27857
2/2
✓ Branch 0 taken 797258 times.
✓ Branch 1 taken 8098 times.
805356 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
27858 {
27859 8098 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
27860 8098 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
27861 8098 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
27862 8098 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
27863 8098 }
27864 805356 do_primitives(framebuf, SPLAYER_PUSHBLOCK, newscr, 0, playing_field_offset);
27865 805356 }
27866
27867 805356 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
27868 805356 do_walkflags(newscr, tx, ty,2);
27869
27870 805356 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
27871 805356 do_effectflags(newscr, tx, ty,2);
27872
27873
27874 805356 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
27875 805356 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
27876 805356 herostep();
27877
1/2
✓ Branch 0 taken 805356 times.
✗ Branch 1 not taken.
805356 if(isForceFaceUp) dir = up;
27878
27879
5/6
✓ Branch 0 taken 805306 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 805256 times.
✓ Branch 4 taken 805306 times.
✓ Branch 5 taken 805306 times.
805356 if((z > 0 || fakez > 0) && (!get_qr(qr_SHADOWSFLICKER) || frame&1))
27880 {
27881 1610562 drawshadow(framebuf, get_qr(qr_TRANSSHADOWS) != 0);
27882 1610562 }
27883
27884
4/4
✓ Branch 0 taken 359686 times.
✓ Branch 1 taken 445670 times.
✓ Branch 2 taken 130439 times.
✓ Branch 3 taken 229247 times.
805356 if(!isdungeon() || get_qr(qr_FREEFORM))
27885 {
27886 576109 draw_under(framebuf); //draw the ladder or raft
27887 576109 decorations.draw2(framebuf, true);
27888 576109 draw(framebuf); //Hero
27889 576109 decorations.draw(framebuf, true);
27890 576109 }
27891
27892
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 805127 times.
805356 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
27893
27894 805356 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
27895 805356 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
27896
2/2
✓ Branch 0 taken 800039 times.
✓ Branch 1 taken 5317 times.
805356 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
27897 {
27898 5317 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
27899 5317 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
27900 5317 }
27901 805356 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
27902 805356 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
27903 805356 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
27904
27905
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 805127 times.
805356 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
27906
27907 805356 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
27908 805356 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
27909
2/2
✓ Branch 0 taken 800039 times.
✓ Branch 1 taken 5317 times.
805356 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
27910 {
27911 5317 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
27912 5317 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
27913 5317 }
27914 805356 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
27915 805356 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
27916 805356 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
27917
27918
27919
1/2
✓ Branch 0 taken 805356 times.
✗ Branch 1 not taken.
805356 if(msg_bg_display_buf->clip == 0)
27920 {
27921 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27922 }
27923
1/2
✓ Branch 0 taken 805356 times.
✗ Branch 1 not taken.
805356 if(msg_portrait_display_buf->clip == 0)
27924 {
27925 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27926 }
27927
1/2
✓ Branch 0 taken 805356 times.
✗ Branch 1 not taken.
805356 if(msg_txt_display_buf->clip == 0)
27928 {
27929 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
27930 }
27931
27932
6/6
✓ Branch 0 taken 11611 times.
✓ Branch 1 taken 793745 times.
✓ Branch 2 taken 11296 times.
✓ Branch 3 taken 315 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 11196 times.
805356 if(get_qr(qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
27933 {
27934 415 clear_darkroom_bitmaps();
27935 415 calc_darkroom_combos(true);
27936 415 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
27937 415 }
27938
27939
4/4
✓ Branch 0 taken 11611 times.
✓ Branch 1 taken 793745 times.
✓ Branch 2 taken 8092 times.
✓ Branch 3 taken 3519 times.
805356 if(get_qr(qr_NEW_DARKROOM) && get_qr(qr_NEWDARK_L6))
27940 {
27941 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27942 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27943 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27944
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
27945 {
27946 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27947 {
27948 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27949 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27950 }
27951
27952 color_map = &trans_table2;
27953 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27954 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27955 else
27956 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
27957 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
27958 color_map = &trans_table;
27959 }
27960
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
27961 {
27962 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27963 {
27964 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
27965 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27966 }
27967
27968 color_map = &trans_table2;
27969 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27970 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
27971 else
27972 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
27973 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
27974 color_map = &trans_table;
27975 }
27976 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
27977 3519 }
27978 805356 put_passive_subscr(framebuf, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
27979
2/2
✓ Branch 0 taken 620462 times.
✓ Branch 1 taken 184894 times.
805356 if(get_qr(qr_SUBSCREENOVERSPRITES))
27980 184894 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
27981
27982
4/4
✓ Branch 0 taken 11611 times.
✓ Branch 1 taken 793745 times.
✓ Branch 2 taken 3519 times.
✓ Branch 3 taken 8092 times.
805356 if(get_qr(qr_NEW_DARKROOM) && !get_qr(qr_NEWDARK_L6))
27983 {
27984 8092 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
27985 8092 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
27986 8092 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
27987
2/2
✓ Branch 0 taken 7777 times.
✓ Branch 1 taken 315 times.
8092 if(newscr->flags & fDARK)
27988 {
27989
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
27990 {
27991 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
27992 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
27993 }
27994
27995 315 color_map = &trans_table2;
27996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
27997 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
27998 else
27999 315 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
28000 315 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
28001 315 color_map = &trans_table;
28002 315 }
28003
2/2
✓ Branch 0 taken 7794 times.
✓ Branch 1 taken 298 times.
8092 if(oldscr->flags & fDARK)
28004 {
28005
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
28006 {
28007 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
28008 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
28009 }
28010
28011 298 color_map = &trans_table2;
28012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298 times.
298 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
28013 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
28014 else
28015 298 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
28016 298 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
28017 298 color_map = &trans_table;
28018 298 }
28019 8092 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28020 8092 }
28021 805356 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
28022
28023 //end drawing
28024 805356 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
28025 805356 advanceframe(true/*,true,false*/);
28026
28027 //Don't clear the last frame, unless 'fixed'
28028
4/4
✓ Branch 0 taken 12885 times.
✓ Branch 1 taken 792471 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 12654 times.
805356 if(cx > 0 || get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
28029 792702 script_drawing_commands.Clear();
28030 805356 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
28031 805356 actiontype lastaction = action;
28032 805356 action=scrolling; FFCore.setHeroAction(scrolling);
28033 805356 FFCore.runF6Engine();
28034 805356 action=lastaction; FFCore.setHeroAction(lastaction);
28035 805356 } //end main scrolling loop
28036 12885 currdmap = olddmap;
28037
28038 12885 clear_bitmap(msg_txt_display_buf);
28039 12885 set_clip_state(msg_txt_display_buf, 1);
28040 12885 clear_bitmap(msg_bg_display_buf);
28041 12885 set_clip_state(msg_bg_display_buf, 1);
28042 12885 clear_bitmap(msg_portrait_display_buf);
28043 12885 set_clip_state(msg_portrait_display_buf, 1);
28044
28045 //Move hero to the other side of the screen if scrolling's not turned on
28046
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(get_qr(qr_NOSCROLL))
28047 {
28048 switch(scrolldir)
28049 {
28050 case up:
28051 y = 160;
28052 break;
28053
28054 case down:
28055 y = 0;
28056 break;
28057
28058 case left:
28059 x = 240;
28060 break;
28061
28062 case right:
28063 x = 0;
28064 break;
28065 }
28066 }
28067
28068
3/4
✓ Branch 0 taken 12884 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12885 times.
✗ Branch 3 not taken.
12885 if((z > 0 || fakez > 0) && isSideViewHero())
28069 {
28070 y -= z;
28071 y -= fakez;
28072 z = 0;
28073 fakez = 0;
28074 }
28075
28076 12885 combotile_add_x = 0;
28077 12885 combotile_add_y = 0;
28078
28079 12885 set_respawn_point(false);
28080 12885 trySideviewLadder();
28081 12885 warpx = -1;
28082 12885 warpy = -1;
28083
28084 12885 screenscrolling = false;
28085 12885 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
28086 12885 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
28087 12885 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
28088 12885 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
28089 12885 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
28090
28091
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 12477 times.
12885 if(destdmap != -1)
28092 {
28093 408 bool changedlevel = false;
28094 408 bool changeddmap = false;
28095
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 314 times.
408 if(olddmap != destdmap)
28096 {
28097 314 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
28098 314 changeddmap = true;
28099 314 }
28100
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 85 times.
408 if(DMaps[olddmap].level != DMaps[destdmap].level)
28101 {
28102 85 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
28103 85 changedlevel = true;
28104 85 }
28105 408 dlevel = DMaps[destdmap].level;
28106 408 currdmap = destdmap;
28107
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 314 times.
408 if(changeddmap)
28108 {
28109 314 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
28110 314 }
28111
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 85 times.
408 if(changedlevel)
28112 {
28113 85 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
28114 85 }
28115 408 }
28116
28117 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
28118 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
28119 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
28120 //direction. -DD
28121
28122
2/2
✓ Branch 0 taken 12721 times.
✓ Branch 1 taken 164 times.
12885 if(nowinwater)
28123 {
28124 164 SetSwim();
28125 164 hopclk = 0xFF;
28126 164 }
28127
28128 // NES behaviour: Fade to light after scrolling
28129 12885 lighting(false, false); // No, we don't need to set naturaldark...
28130
28131 12885 init_dmap();
28132 12885 putscr(scrollbuf,0,0,newscr);
28133 12885 putscrdoors(scrollbuf,0,0,newscr);
28134
28135 // Check for raft flags
28136
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 12447 times.
25389 if((get_qr(qr_BROKEN_RAFT_SCROLL) || lastaction == rafting)
28137
4/4
✓ Branch 0 taken 12668 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 12504 times.
✓ Branch 3 taken 164 times.
12885 && action!=rafting && hopclk==0 && !toogam)
28138 {
28139
3/4
✓ Branch 0 taken 12444 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12444 times.
12447 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
28140 {
28141 3 sfx(tmpscr->secretsfx);
28142 3 action=rafting; FFCore.setHeroAction(rafting);
28143 3 raftclk=0;
28144 3 }
28145
28146 // Half a tile off?
28147
6/8
✓ Branch 0 taken 9394 times.
✓ Branch 1 taken 3050 times.
✓ Branch 2 taken 3528 times.
✓ Branch 3 taken 5866 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6578 times.
✓ Branch 6 taken 12444 times.
✗ Branch 7 not taken.
19022 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
28148 {
28149 sfx(tmpscr->secretsfx);
28150 action=rafting; FFCore.setHeroAction(rafting);
28151 raftclk=0;
28152 }
28153 12447 }
28154
28155 12885 opendoors=0;
28156 12885 markBmap(-1);
28157
28158
2/2
✓ Branch 0 taken 8383 times.
✓ Branch 1 taken 4502 times.
12885 if(isdungeon())
28159 {
28160
3/3
✓ Branch 0 taken 2572 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 766 times.
4502 switch(tmpscr->door[scrolldir^1])
28161 {
28162 case dOPEN:
28163 case dUNLOCKED:
28164 case dOPENBOSS:
28165 2572 dir = scrolldir;
28166
28167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2572 times.
2572 if(action!=rafting)
28168 2572 stepforward(diagonalMovement?11:12, false);
28169
28170 2572 break;
28171
28172 case dSHUTTER:
28173 case d1WAYSHUTTER:
28174 1164 dir = scrolldir;
28175
28176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1164 times.
1164 if(action!=rafting)
28177 1164 stepforward(diagonalMovement?21:24, false);
28178
28179 1164 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
28180 1164 opendoors=-4;
28181 1164 sfx(WAV_DOOR);
28182 1164 break;
28183
28184 default:
28185 766 dir = scrolldir;
28186
28187
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 719 times.
766 if(action!=rafting)
28188 719 stepforward(diagonalMovement?21:24, false);
28189 766 }
28190 4502 }
28191
28192
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(isForceFaceUp) dir = up;
28193
28194
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(action == scrolling)
28195 {
28196 action=none; FFCore.setHeroAction(none);
28197 }
28198
28199
2/4
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12885 times.
12885 if(action != attacking && action != sideswimattacking)
28200 {
28201 12885 charging = 0;
28202 12885 tapping = false;
28203 12885 }
28204
28205 12885 map_bkgsfx(true);
28206
28207
2/2
✓ Branch 0 taken 12855 times.
✓ Branch 1 taken 30 times.
12885 if(newscr->flags2&fSECRET)
28208 {
28209 30 sfx(newscr->secretsfx);
28210 30 }
28211
28212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12885 times.
12885 if (updatemusic)
28213 {
28214 12885 playLevelMusic();
28215
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if (musicrevert)
28216 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
28217 12885 }
28218
28219 12885 newscr_clk = frame;
28220 12885 activated_timed_warp=false;
28221 12885 loadside = scrolldir^1;
28222 12885 FFCore.clear_combo_scripts();
28223 12885 eventlog_mapflags();
28224 12885 decorations.animate(); //continue to animate tall grass during scrolling
28225
2/2
✓ Branch 0 taken 12654 times.
✓ Branch 1 taken 231 times.
12885 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
28226 {
28227
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
231 if(olddmap == newdmap || (replay_version_check(0, 15)))
28228 231 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
28229 else refresh_dmap_scrollscript = true;
28230 231 }
28231
1/2
✓ Branch 0 taken 12885 times.
✗ Branch 1 not taken.
12885 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
28232 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
28233 12885 }
28234
28235
28236
28237 // How much to reduce Hero's damage, taking into account various rings.
28238 7568 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
28239 {
28240
1/2
✓ Branch 0 taken 7568 times.
✗ Branch 1 not taken.
7568 if(dmg < 0) return dmg; //Don't reduce healing
28241
2/2
✓ Branch 0 taken 7441 times.
✓ Branch 1 taken 127 times.
7568 if ( get_qr(qr_BROKEN_RING_POWER) )
28242 {
28243 7441 int32_t divisor = 1;
28244 7441 float percentage = 1;
28245 7441 int32_t itemid = current_item_id(itype_ring);
28246 7441 bool usering = false;
28247
28248
4/4
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 2297 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 5107 times.
7441 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28249 {
28250 5107 usering = true;
28251 5107 paymagiccost(itemid);
28252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5107 times.
5107 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28253 {
28254 percentage *= itemsbuf[itemid].power/100.0;
28255 }
28256 else
28257 {
28258 5107 divisor *= itemsbuf[itemid].power;
28259 }
28260 5107 }
28261
28262 /* Now for the Peril Ring */
28263 7441 itemid = current_item_id(itype_perilring);
28264
28265
7/10
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 6640 times.
✓ Branch 2 taken 801 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 374 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 374 times.
7441 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28266 {
28267 374 usering = true;
28268 374 paymagiccost(itemid);
28269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28270 {
28271 percentage *= itemsbuf[itemid].power/100.0;
28272 }
28273 else
28274 {
28275 374 divisor *= itemsbuf[itemid].power;
28276 }
28277 374 }
28278
28279 // Ring divisor of 0 = no damage. -L
28280
4/6
✓ Branch 0 taken 5114 times.
✓ Branch 1 taken 2327 times.
✓ Branch 2 taken 5114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5114 times.
7441 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28281 return 0;
28282
28283
1/2
✓ Branch 0 taken 7441 times.
✗ Branch 1 not taken.
7441 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
28284
28285
1/2
✓ Branch 0 taken 7441 times.
✗ Branch 1 not taken.
7441 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
28286
1/2
✓ Branch 0 taken 7441 times.
✗ Branch 1 not taken.
7441 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28287
28288 }
28289 else
28290 {
28291 127 double divisor = 1;
28292 127 double percentage = 1;
28293 127 int32_t itemid = current_item_id(itype_ring);
28294 127 bool usering = false;
28295
28296
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
127 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
28297 {
28298 3 usering = true;
28299 3 paymagiccost(itemid);
28300
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28301 {
28302 1 double perc = itemsbuf[itemid].power/100.0;
28303
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28304 1 percentage *= perc;
28305 1 }
28306 else
28307 {
28308
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
28309 divisor /= -(itemsbuf[itemid].power);
28310 2 else divisor *= itemsbuf[itemid].power;
28311 }
28312 3 }
28313
28314 /* Now for the Peril Ring */
28315 127 itemid = current_item_id(itype_perilring);
28316
28317
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
127 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
28318 {
28319 usering = true;
28320 paymagiccost(itemid);
28321 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
28322 {
28323 double perc = itemsbuf[itemid].power/100.0;
28324 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
28325 percentage *= perc;
28326 }
28327 else
28328 {
28329 if(itemsbuf[itemid].power < 0)
28330 divisor /= -(itemsbuf[itemid].power);
28331 else divisor *= itemsbuf[itemid].power;
28332 }
28333 }
28334
28335 // Ring divisor of 0 = no damage. -L
28336
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
127 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
28337 return 0;
28338
28339 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
28340
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
28341 }
28342 7568 }
28343
28344 // Should swinging the hammer make the 'pound' sound?
28345 // Or is Hero just hitting air?
28346 2216 bool HeroClass::sideviewhammerpound()
28347 {
28348 2216 int32_t wx=0,wy=0;
28349
28350
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 638 times.
✓ Branch 4 taken 740 times.
2216 switch(dir)
28351 {
28352 case up:
28353 350 wx=-1;
28354 350 wy=-15;
28355
28356
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(isSideViewHero()) wy+=8;
28357
28358 350 break;
28359
28360 case down:
28361 488 wx=8;
28362 488 wy=28;
28363
28364
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(isSideViewHero()) wy-=8;
28365
28366 488 break;
28367
28368 case left:
28369 638 wx=-8;
28370 638 wy=14;
28371
28372
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 6 times.
638 if(isSideViewHero()) wy+=8;
28373
28374 638 break;
28375
28376 case right:
28377 740 wx=21;
28378 740 wy=14;
28379
28380
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(isSideViewHero()) wy+=8;
28381
28382 740 break;
28383 }
28384
28385
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2210 times.
2216 if(!isSideViewHero())
28386 {
28387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2210 times.
2210 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
28388 }
28389
28390
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28391
28392 if(dir==left || dir==right)
28393 {
28394 wx+=16;
28395
28396 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
28397 }
28398
28399 return false;
28400 2216 }
28401
28402 /************************************/
28403 /******** More Items Code *********/
28404 /************************************/
28405
28406 // The following are only used for Hero damage. Damage is in quarter hearts.
28407 4230 int32_t enemy_dp(int32_t index)
28408 {
28409 4230 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
28410 }
28411
28412 3115 int32_t ewpn_dp(int32_t index)
28413 {
28414 3115 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
28415 }
28416
28417 27 int32_t lwpn_dp(int32_t index)
28418 {
28419 27 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
28420 }
28421
28422 108912742 bool checkbunny(int32_t itemid)
28423 {
28424
3/4
✓ Branch 0 taken 108808076 times.
✓ Branch 1 taken 104666 times.
✓ Branch 2 taken 104666 times.
✗ Branch 3 not taken.
108912742 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
28425 }
28426
28427 25953539 bool usesSwordJinx(int32_t itemid)
28428 {
28429 25953539 itemdata const& it = itemsbuf[itemid];
28430 25953539 bool ret = (it.family==itype_sword);
28431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25953539 times.
25953539 if(it.flags & ITEM_FLIP_JINX) return !ret;
28432 25953539 return ret;
28433 25953539 }
28434 22646713 bool checkitem_jinx(int32_t itemid)
28435 {
28436 22646713 itemdata const& it = itemsbuf[itemid];
28437
2/2
✓ Branch 0 taken 1416 times.
✓ Branch 1 taken 22645297 times.
22646713 if(it.flags & ITEM_JINX_IMMUNE) return true;
28438
2/2
✓ Branch 0 taken 5936821 times.
✓ Branch 1 taken 16708476 times.
22645297 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
28439 16708476 return HeroItemClk() == 0;
28440 22646713 }
28441
28442 439057 int32_t Bweapon(int32_t pos)
28443 {
28444
4/4
✓ Branch 0 taken 439055 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 888 times.
✓ Branch 3 taken 438167 times.
439057 if(pos < 0 || current_subscreen_active == NULL)
28445 {
28446 890 return 0;
28447 }
28448
28449 438167 int32_t p=-1;
28450
28451
4/4
✓ Branch 0 taken 147147 times.
✓ Branch 1 taken 12122251 times.
✓ Branch 2 taken 147147 times.
✓ Branch 3 taken 12122251 times.
12269398 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
28452 {
28453
4/4
✓ Branch 0 taken 8790243 times.
✓ Branch 1 taken 3332008 times.
✓ Branch 2 taken 8499223 times.
✓ Branch 3 taken 291020 times.
12122251 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
28454 {
28455 291020 p=i;
28456 291020 break;
28457 }
28458 11831231 }
28459
28460
2/2
✓ Branch 0 taken 291020 times.
✓ Branch 1 taken 147147 times.
438167 if(p==-1)
28461 {
28462 147147 return 0;
28463 }
28464
28465 291020 int32_t actualItem = current_subscreen_active->objects[p].d8;
28466 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
28467 291020 int32_t family = -1;
28468 291020 bool bow = false;
28469
28470
2/2
✓ Branch 0 taken 9529 times.
✓ Branch 1 taken 281491 times.
291020 if(actualItem)
28471 {
28472 9529 bool select = false;
28473
28474
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6226 times.
9529 switch(itemsbuf[actualItem-1].family)
28475 {
28476 case itype_bomb:
28477 if((game->get_bombs() ||
28478 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28479 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
28480 current_item_power(itype_bombbag))
28481 {
28482 select=true;
28483 }
28484
28485 break;
28486
28487 case itype_bowandarrow:
28488 case itype_arrow:
28489 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
28490 {
28491 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28492 select=true;
28493 }
28494
28495 break;
28496
28497 case itype_letterpotion:
28498 /*if(current_item_id(itype_potion)>-1)
28499 {
28500 select=true;
28501 }
28502 else if(current_item_id(itype_letter)>-1)
28503 {
28504 select=true;
28505 }*/
28506 break;
28507
28508 case itype_sbomb:
28509 {
28510 int32_t bombbagid = current_item_id(itype_bombbag);
28511
28512 if((game->get_sbombs() ||
28513 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28514 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
28515 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28516 {
28517 select=true;
28518 }
28519
28520 break;
28521 }
28522
28523 case itype_sword:
28524 {
28525
1/2
✓ Branch 0 taken 6226 times.
✗ Branch 1 not taken.
6226 if(!get_qr(qr_SELECTAWPN))
28526 break;
28527
28528 6226 select=true;
28529 }
28530 6226 break;
28531
28532 default:
28533 3303 select=true;
28534 3303 }
28535
28536
4/6
✓ Branch 0 taken 9529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7657 times.
✓ Branch 3 taken 1872 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7657 times.
9529 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
28537 {
28538 7657 directItem = actualItem-1;
28539
28540
2/4
✓ Branch 0 taken 7657 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7657 times.
✗ Branch 3 not taken.
7657 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
28541
28542 7657 return actualItem-1+(bow?0xF000:0);
28543 }
28544 1872 else return 0;
28545 }
28546
28547 281491 directItem = -1;
28548
28549
6/6
✓ Branch 0 taken 27117 times.
✓ Branch 1 taken 3484 times.
✓ Branch 2 taken 231396 times.
✓ Branch 3 taken 13757 times.
✓ Branch 4 taken 4240 times.
✓ Branch 5 taken 1497 times.
281491 switch(current_subscreen_active->objects[p].d1)
28550 {
28551 case itype_bomb:
28552 {
28553 27117 int32_t bombid = current_item_id(itype_bomb);
28554
28555
4/4
✓ Branch 0 taken 5926 times.
✓ Branch 1 taken 21191 times.
✓ Branch 2 taken 214 times.
✓ Branch 3 taken 5712 times.
33043 if((game->get_bombs() ||
28556 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28557
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 5656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 270 times.
5926 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
28558 5926 current_item_power(itype_bombbag))
28559 {
28560 21405 family=itype_bomb;
28561 21405 }
28562
28563 27117 break;
28564 }
28565
28566 case itype_bowandarrow:
28567 case itype_arrow:
28568
4/4
✓ Branch 0 taken 11994 times.
✓ Branch 1 taken 1763 times.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 17 times.
13757 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
28569 {
28570 11977 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
28571 11977 family=itype_arrow;
28572 11977 }
28573
28574 13757 break;
28575
28576 case itype_letterpotion:
28577
2/2
✓ Branch 0 taken 2043 times.
✓ Branch 1 taken 2197 times.
4240 if(current_item_id(itype_potion)>-1)
28578 {
28579 2043 family=itype_potion;
28580 2043 }
28581
2/2
✓ Branch 0 taken 1708 times.
✓ Branch 1 taken 489 times.
2197 else if(current_item_id(itype_letter)>-1)
28582 {
28583 489 family=itype_letter;
28584 489 }
28585
28586 4240 break;
28587
28588 case itype_sbomb:
28589 {
28590 3484 int32_t bombbagid = current_item_id(itype_bombbag);
28591 3484 int32_t sbombid = current_item_id(itype_sbomb);
28592
28593
3/4
✓ Branch 0 taken 1733 times.
✓ Branch 1 taken 1751 times.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
3644 if((game->get_sbombs() ||
28594 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
28595
3/4
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1510 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 223 times.
1733 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
28596
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1573 times.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
1733 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
28597 {
28598 1911 family=itype_sbomb;
28599 1911 }
28600
28601 3484 break;
28602 }
28603
28604 case itype_sword:
28605 {
28606
2/2
✓ Branch 0 taken 1449 times.
✓ Branch 1 taken 48 times.
1497 if(!get_qr(qr_SELECTAWPN))
28607 48 break;
28608
28609 1449 family=itype_sword;
28610 }
28611 1449 break;
28612
28613 default:
28614 231396 family=current_subscreen_active->objects[p].d1;
28615 231396 }
28616
28617
2/2
✓ Branch 0 taken 270670 times.
✓ Branch 1 taken 10821 times.
281491 if(family==-1)
28618 10821 return 0;
28619
28620
2/2
✓ Branch 0 taken 13379448 times.
✓ Branch 1 taken 21285 times.
13400733 for(int32_t j=0; j<MAXITEMS; j++)
28621 {
28622 // Find the item that matches this subscreen object.
28623
5/6
✓ Branch 0 taken 451296 times.
✓ Branch 1 taken 12928152 times.
✓ Branch 2 taken 249385 times.
✓ Branch 3 taken 201911 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 249385 times.
13379448 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
28624 {
28625 249385 return j+(bow?0xF000:0);
28626 }
28627 13130063 }
28628
28629 21285 return 0;
28630 439057 }
28631
28632 93 int32_t BWeapon_to_Pos(int32_t bweapon)
28633 {
28634
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
28635 {
28636
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
28637 {
28638 74 return i;
28639 }
28640 5198 }
28641 19 return -1;
28642 93 }
28643
28644 2 void stopCaneOfByrna()
28645 {
28646
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
28647 {
28648 40 weapon *w = ((weapon*)Lwpns.spr(i));
28649
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
28650 2 w->dead=1;
28651 40 }
28652 2 }
28653
28654 /* Crashes if used by ffscript.cpp, in case LINKITEMD
28655 void stopCaneOfByrna()
28656 {
28657 byte prnt_cane = -1;
28658 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
28659 prnt_cane = ew->parentitem;
28660 for(int32_t i=0; i<Lwpns.Count(); i++)
28661 {
28662 weapon *w = ((weapon*)Lwpns.spr(i));
28663
28664 if(w->id==wCByrna)
28665 {
28666 w->dead=1;
28667 }
28668 }
28669 if ( prnt_cane > -1 )
28670 {
28671 stop_sfx(itemsbuf[prnt_cane].usesound);
28672 }
28673 }
28674 */
28675 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
28676 7261207 void HeroClass::cleanupByrna()
28677 {
28678
2/2
✓ Branch 0 taken 7261130 times.
✓ Branch 1 taken 77 times.
7261207 if ( last_cane_of_byrna_item_id > -1 )
28679 {
28680 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
28681
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
28682 {
28683 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
28684 2 last_cane_of_byrna_item_id = -1;
28685 2 }
28686 77 }
28687 7261207 }
28688
28689 // Used to find out if an item family is attached to one of the buttons currently pressed.
28690 2129943 bool isWpnPressed(int32_t itype)
28691 {
28692 //0xFFF for subscreen overrides
28693 //Will crash on win10 without it! -Z
28694
4/4
✓ Branch 0 taken 404296 times.
✓ Branch 1 taken 1725647 times.
✓ Branch 2 taken 368743 times.
✓ Branch 3 taken 35553 times.
2129943 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
28695
4/4
✓ Branch 0 taken 770990 times.
✓ Branch 1 taken 1323400 times.
✓ Branch 2 taken 316610 times.
✓ Branch 3 taken 454380 times.
2094390 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
28696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640010 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640010 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
28697
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1639990 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1640010 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
28698 1639990 return false;
28699 2129943 }
28700
28701 3914686 int32_t getWpnPressed(int32_t itype)
28702 {
28703
4/4
✓ Branch 0 taken 177199 times.
✓ Branch 1 taken 3737487 times.
✓ Branch 2 taken 171856 times.
✓ Branch 3 taken 5343 times.
3914686 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
28704
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3908757 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3909343 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
28705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3908757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3908757 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
28706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3908757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3908757 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
28707
28708 3908757 return -1;
28709 3914686 }
28710
28711 7262873 int32_t getRocsPressed()
28712 {
28713 7262873 int32_t jumpid = current_item_id(itype_rocs,true,true);
28714
28715
2/2
✓ Branch 0 taken 184646 times.
✓ Branch 1 taken 7078227 times.
7262873 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
28716
28717
2/2
✓ Branch 0 taken 7078227 times.
✓ Branch 1 taken 184646 times.
7262873 if (jumpid != -1)
28718 {
28719 184646 itemdata const& itm = itemsbuf[jumpid];
28720
28721 184646 byte intbtn = byte(itm.misc2&0xFF);
28722
1/2
✓ Branch 0 taken 184646 times.
✗ Branch 1 not taken.
184646 if(getIntBtnInput(intbtn, false, true, false, false, true))
28723 return jumpid; //not pressed
28724 184646 }
28725
28726
4/4
✓ Branch 0 taken 4610 times.
✓ Branch 1 taken 7258263 times.
✓ Branch 2 taken 4306 times.
✓ Branch 3 taken 304 times.
7262873 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn())
28727 304 return Bwpn;
28728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262569 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn())
28729 return Awpn;
28730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262569 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn())
28731 return Xwpn;
28732
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7262569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7262569 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn())
28733 return Ywpn;
28734
28735 7262569 return -1;
28736 7262873 }
28737
28738 bool isItmPressed(int32_t itmid)
28739 {
28740 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
28741 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
28742 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
28743 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
28744 return false;
28745 }
28746
28747 5581 void selectNextAWpn(int32_t type)
28748 {
28749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5581 times.
5581 if(!get_qr(qr_SELECTAWPN))
28750 return;
28751
28752
2/4
✓ Branch 0 taken 5581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5581 times.
5581 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28753 5581 Awpn = Bweapon(ret);
28754 5581 directItemA = directItem;
28755 5581 game->awpn = ret;
28756 5581 }
28757
28758 12638 void selectNextBWpn(int32_t type)
28759 {
28760
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12638 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12638 times.
12638 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28761 12638 Bwpn = Bweapon(ret);
28762 12638 directItemB = directItem;
28763 12638 game->bwpn = ret;
28764 12638 }
28765
28766 void selectNextXWpn(int32_t type)
28767 {
28768 if(!get_qr(qr_SET_XBUTTON_ITEMS)) return;
28769 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
28770 Xwpn = Bweapon(ret);
28771 directItemX = directItem;
28772 game->xwpn = ret;
28773 }
28774
28775 void selectNextYWpn(int32_t type)
28776 {
28777 if(!get_qr(qr_SET_YBUTTON_ITEMS)) return;
28778 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
28779 Ywpn = Bweapon(ret);
28780 directItemY = directItem;
28781 game->ywpn = ret;
28782 }
28783
28784 61811 void verifyAWpn()
28785 {
28786
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 60792 times.
61811 if ( (game->forced_awpn != -1) )
28787 {
28788 1019 return;
28789 }
28790
2/2
✓ Branch 0 taken 6850 times.
✓ Branch 1 taken 53942 times.
60792 if(!get_qr(qr_SELECTAWPN))
28791 {
28792 53942 Awpn = selectSword();
28793 53942 game->awpn = 0xFF;
28794 53942 }
28795 else
28796 {
28797 6850 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
28798 6850 Awpn = Bweapon(game->awpn);
28799 6850 directItemA = directItem;
28800 }
28801 61811 }
28802
28803 59220 void verifyBWpn()
28804 {
28805
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 58207 times.
59220 if ( (game->forced_bwpn != -1) )
28806 {
28807 1013 return;
28808 }
28809 58207 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
28810 58207 Bwpn = Bweapon(game->bwpn);
28811 58207 directItemB = directItem;
28812 59220 }
28813
28814 59220 void verifyXWpn()
28815 {
28816
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 58207 times.
59220 if ( (game->forced_xwpn != -1) )
28817 {
28818 1013 return;
28819 }
28820
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 58143 times.
58207 if(get_qr(qr_SET_XBUTTON_ITEMS))
28821 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
28822 58143 else game->xwpn = -1;
28823 58207 Xwpn = Bweapon(game->xwpn);
28824 58207 directItemX = directItem;
28825 59220 }
28826
28827 59220 void verifyYWpn()
28828 {
28829
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 58207 times.
59220 if ( (game->forced_ywpn != -1) )
28830 {
28831 1013 return;
28832 }
28833
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 58143 times.
58207 if(get_qr(qr_SET_YBUTTON_ITEMS))
28834 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
28835 58143 else game->ywpn = -1;
28836 58207 Ywpn = Bweapon(game->ywpn);
28837 58207 directItemY = directItem;
28838 59220 }
28839
28840 59220 void verifyBothWeapons()
28841 {
28842 59220 verifyAWpn();
28843 59220 verifyBWpn();
28844 59220 verifyXWpn();
28845 59220 verifyYWpn();
28846 59220 }
28847
28848 234359 int get_subscr_itemind(int32_t pos)
28849 {
28850
1/2
✓ Branch 0 taken 234359 times.
✗ Branch 1 not taken.
234359 if(current_subscreen_active == NULL)
28851 return -1;
28852 234359 auto* objects = current_subscreen_active->objects;
28853
2/2
✓ Branch 0 taken 6315436 times.
✓ Branch 1 taken 7890 times.
6323326 for(int32_t i=0; objects[i].type!=ssoNULL; ++i)
28854 {
28855
2/2
✓ Branch 0 taken 1727584 times.
✓ Branch 1 taken 4587852 times.
6315436 if(objects[i].type==ssoCURRENTITEM)
28856 {
28857
2/2
✓ Branch 0 taken 226469 times.
✓ Branch 1 taken 4361383 times.
4587852 if(objects[i].d3==pos)
28858 226469 return i;
28859 4361383 }
28860 6088967 }
28861 7890 return -1;
28862 234359 }
28863 85114 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3, bool equip_only, bool checkwpn)
28864 {
28865 //what will be returned when all else fails.
28866 //don't return the forbiddenpos... no matter what -DD
28867
28868 85114 int32_t failpos(0);
28869
28870
6/6
✓ Branch 0 taken 66921 times.
✓ Branch 1 taken 18193 times.
✓ Branch 2 taken 66747 times.
✓ Branch 3 taken 174 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 66743 times.
85114 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
28871 18371 failpos = 0xFF;
28872 66743 else failpos = startpos;
28873
28874 // verify startpos
28875
3/4
✓ Branch 0 taken 85114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18382 times.
✓ Branch 3 taken 66732 times.
85114 if(startpos < 0 || startpos >= 0xFF)
28876 18382 startpos = 0;
28877
28878
2/2
✓ Branch 0 taken 84804 times.
✓ Branch 1 taken 310 times.
85114 if(current_subscreen_active == NULL)
28879 310 return failpos;
28880 84804 auto* objects = current_subscreen_active->objects;
28881
28882
2/2
✓ Branch 0 taken 83993 times.
✓ Branch 1 taken 811 times.
84804 checkwpn = checkwpn || !get_qr(qr_FREEFORM_SUBSCREEN_CURSOR);
28883
2/2
✓ Branch 0 taken 65003 times.
✓ Branch 1 taken 19801 times.
84804 bool verify = type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT;
28884
28885
2/2
✓ Branch 0 taken 19039 times.
✓ Branch 1 taken 65765 times.
84804 if(verify)
28886 {
28887 65765 int32_t wpn = Bweapon(startpos);
28888 65765 equip_only = checkwpn = true;
28889 65765 auto startind = get_subscr_itemind(startpos);
28890
3/4
✓ Branch 0 taken 57917 times.
✓ Branch 1 taken 7848 times.
✓ Branch 2 taken 57917 times.
✗ Branch 3 not taken.
65765 if(objects[startind].type==ssoCURRENTITEM&&(objects[startind].d2&SSCURRITEM_NONEQUIP))
28891 wpn = 0;
28892
28893
6/8
✓ Branch 0 taken 56094 times.
✓ Branch 1 taken 9671 times.
✓ Branch 2 taken 56073 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56073 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 56073 times.
65765 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
28894 {
28895 56073 return startpos;
28896 }
28897 9692 }
28898
28899 28731 int32_t p=-1;
28900 28731 int32_t curpos = startpos;
28901 28731 int32_t firstValidPos=-1, firstValidEquipPos=-1;
28902
28903
2/2
✓ Branch 0 taken 17744 times.
✓ Branch 1 taken 305223 times.
322967 for(int32_t i=0; objects[i].type!=ssoNULL; ++i)
28904 {
28905
2/2
✓ Branch 0 taken 98462 times.
✓ Branch 1 taken 206761 times.
305223 if(objects[i].type==ssoCURRENTITEM)
28906 {
28907
4/4
✓ Branch 0 taken 165202 times.
✓ Branch 1 taken 41559 times.
✓ Branch 2 taken 154215 times.
✓ Branch 3 taken 10987 times.
206761 if(firstValidPos==-1 && objects[i].d3>=0)
28908 10987 firstValidPos=i;
28909
4/4
✓ Branch 0 taken 165202 times.
✓ Branch 1 taken 41559 times.
✓ Branch 2 taken 154215 times.
✓ Branch 3 taken 10987 times.
206761 if(firstValidEquipPos==-1 && objects[i].d3>=0)
28910
3/4
✓ Branch 0 taken 10167 times.
✓ Branch 1 taken 820 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10167 times.
21974 if(!equip_only || !(objects[i].d2&SSCURRITEM_NONEQUIP))
28911 10987 firstValidEquipPos=i;
28912
28913
2/2
✓ Branch 0 taken 195774 times.
✓ Branch 1 taken 10987 times.
206761 if(objects[i].d3==curpos)
28914 10987 p=i;
28915
4/6
✓ Branch 0 taken 10987 times.
✓ Branch 1 taken 195774 times.
✓ Branch 2 taken 10987 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10987 times.
206761 if(p>-1 && firstValidPos>-1 && firstValidEquipPos>-1)
28916 10987 break;
28917 195774 }
28918 294236 }
28919
28920
2/2
✓ Branch 0 taken 10987 times.
✓ Branch 1 taken 17744 times.
28731 if(p == -1)
28921 {
28922 //can't find the current position
28923 // Switch to a valid weapon if there is one; otherwise,
28924 // the selector can simply disappear
28925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17744 times.
17744 if(firstValidEquipPos>=0)
28926 return objects[firstValidEquipPos].d3;
28927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17744 times.
17744 if(firstValidPos>=0)
28928 return objects[firstValidPos].d3;
28929 //FAILURE
28930 17744 else return failpos;
28931 }
28932
28933 //remember we've been here
28934 10987 set<int32_t> oldPositions;
28935
1/2
✓ Branch 0 taken 10987 times.
✗ Branch 1 not taken.
10987 oldPositions.insert(curpos);
28936
28937 //1. Perform any shifts required by the above
28938 //2. If that's not possible, go to position 1 and reset the b weapon.
28939 //2a. -if we arrive at a position we've already visited, give up and stay there
28940 //3. Get the weapon at the new slot
28941 //4. If it's not possible, go to step 1.
28942
28943 38342 for(;;)
28944 {
28945 //shift
28946
4/5
✓ Branch 0 taken 5266 times.
✓ Branch 1 taken 32938 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 102 times.
38342 switch(type)
28947 {
28948 case SEL_LEFT:
28949 case SEL_VERIFY_LEFT:
28950 5266 curpos = objects[p].d6;
28951 5266 break;
28952
28953 case SEL_RIGHT:
28954 case SEL_VERIFY_RIGHT:
28955 32938 curpos = objects[p].d7;
28956 32938 break;
28957
28958 case SEL_DOWN:
28959 36 curpos = objects[p].d5;
28960 36 break;
28961
28962 case SEL_UP:
28963 102 curpos = objects[p].d4;
28964 102 break;
28965 }
28966
28967 //find our new position
28968 38342 p = get_subscr_itemind(curpos);
28969
28970
1/2
✓ Branch 0 taken 38342 times.
✗ Branch 1 not taken.
38342 if(p == -1)
28971 {
28972 //can't find the current position
28973 //FAILURE
28974 return failpos;
28975 }
28976
28977 //if we've already been here, give up
28978
3/4
✓ Branch 0 taken 38342 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36543 times.
✓ Branch 3 taken 1799 times.
38342 if(oldPositions.find(curpos) != oldPositions.end())
28979 1799 return failpos;
28980
28981 //else, remember we've been here
28982
1/2
✓ Branch 0 taken 36543 times.
✗ Branch 1 not taken.
36543 oldPositions.insert(curpos);
28983
28984 //see if this weapon is acceptable
28985
1/2
✓ Branch 0 taken 36543 times.
✗ Branch 1 not taken.
36543 auto wpn = Bweapon(curpos);
28986
6/6
✓ Branch 0 taken 36332 times.
✓ Branch 1 taken 211 times.
✓ Branch 2 taken 36322 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 36314 times.
36543 if(curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
28987
3/4
✓ Branch 0 taken 35300 times.
✓ Branch 1 taken 1014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35300 times.
63440 if(!equip_only || !(objects[p].d2 & SSCURRITEM_NONEQUIP))
28988
3/4
✓ Branch 0 taken 36314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9188 times.
✓ Branch 3 taken 27126 times.
36314 if(!checkwpn || wpn)
28989 9188 return curpos;
28990 //keep going otherwise
28991 }
28992 85114 }
28993
28994 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
28995 54058 int32_t selectSword()
28996 {
28997 54058 auto ret = current_item_id(itype_sword);
28998
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 52530 times.
54058 if(ret == -1) return 0;
28999 52530 return ret;
29000 54058 }
29001
29002 // Adding code here for allowing hardcoding a button to a specific itemclass.
29003 int32_t selectItemclass(int32_t itemclass)
29004 {
29005 int32_t ret = current_item_id(itemclass);
29006
29007 if(ret == -1)
29008 ret = 0;
29009
29010 return ret;
29011 }
29012
29013 // Used for the 'Pickup Hearts' item pickup condition.
29014 114 bool canget(int32_t id)
29015 {
29016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
29017 }
29018
29019 38 void dospecialmoney(int32_t index)
29020 {
29021 38 int32_t tmp=currscr>=128?1:0;
29022 38 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
29023
29024
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
38 switch(tmpscr[tmp].room)
29025 {
29026 case rINFO: // pay for info
29027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
29028 {
29029
29030
29031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(!current_item_power(itype_wallet))
29032 {
29033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (game->get_spendable_rupies() < abs(prices[priceindex]))
29034 return;
29035 5 int32_t tmpprice = -abs(prices[priceindex]);
29036 5 int32_t total = game->get_drupy()-tmpprice;
29037 5 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29038 5 game->set_drupy(game->get_drupy()-total);
29039 //game->change_drupy(-abs(prices[priceindex]));
29040 5 }
29041
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if ( current_item_power(itype_wallet)>0 )
29042 {
29043 game->change_drupy(0);
29044 }
29045 5 }
29046 5 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
29047 5 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
29048 5 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
29049 5 clear_bitmap(pricesdisplaybuf);
29050 5 set_clip_state(pricesdisplaybuf, 1);
29051 5 items.del(0);
29052
29053
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 5 times.
20 for(int32_t i=0; i<items.Count(); i++)
29054 15 ((item*)items.spr(i))->pickup=ipDUMMY;
29055
29056 // Prevent the prices from being displayed anymore
29057
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 5 times.
20 for(int32_t i=0; i<3; i++)
29058 {
29059 15 prices[i] = 0;
29060 15 }
29061
29062 5 break;
29063
29064 case rMONEY: // secret money
29065 {
29066 14 ((item*)items.spr(0))->pickup = ipDUMMY;
29067
29068 14 prices[0] = tmpscr[tmp].catchall;
29069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (!current_item_power(itype_wallet))
29070 14 game->change_drupy(prices[0]);
29071 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
29072
29073 14 putprices(false);
29074
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29075 14 break;
29076 }
29077
29078 case rGAMBLE: // gamble
29079 {
29080 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
29081
29082 unsigned si=(zc_oldrand()%24)*3;
29083
29084 for(int32_t i=0; i<3; i++)
29085 prices[i]=gambledat[si++];
29086
29087 game->set_drupy(game->get_drupy()+prices[priceindex]);
29088 putprices(true);
29089
29090 for(int32_t i=1; i<4; i++)
29091 ((item*)items.spr(i))->pickup=ipDUMMY;
29092 }
29093 break;
29094
29095 case rBOMBS:
29096 {
29097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29098 return;
29099
29100 8 int32_t price = -tmpscr[tmp].catchall;
29101 8 int32_t wmedal = current_item_id(itype_wealthmedal);
29102
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(wmedal >= 0)
29103 {
29104 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
29105 price*=(itemsbuf[wmedal].misc1/100.0);
29106 else
29107 price+=itemsbuf[wmedal].misc1;
29108 }
29109
29110 8 int32_t total = game->get_drupy()-price;
29111 8 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29112 8 game->set_drupy(game->get_drupy()-total);
29113 //game->set_drupy(game->get_drupy()+price);
29114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29115 8 game->change_maxbombs(4);
29116 8 game->set_bombs(game->get_maxbombs());
29117 {
29118 8 int32_t div = zinit.bomb_ratio;
29119
29120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(div > 0)
29121 8 game->change_maxcounter(4/div, 6);
29122 }
29123
29124 //also give Hero an actual Bomb item
29125
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<MAXITEMS; i++)
29126 {
29127
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2038 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
2048 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
29128 8 getitem(i, true, true);
29129 2048 }
29130
29131 8 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29132 8 fadeclk=66;
29133 8 dismissmsg();
29134 8 clear_bitmap(pricesdisplaybuf);
29135 8 set_clip_state(pricesdisplaybuf, 1);
29136 // putscr(scrollbuf,0,0,tmpscr);
29137 8 verifyBothWeapons();
29138 8 break;
29139 }
29140
29141 case rARROWS:
29142 {
29143 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29144 return;
29145
29146 int32_t price = -tmpscr[tmp].catchall;
29147 int32_t wmedal = current_item_id(itype_wealthmedal);
29148 if(wmedal >= 0)
29149 {
29150 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
29151 price*=(itemsbuf[wmedal].misc1/100.0);
29152 else
29153 price+=itemsbuf[wmedal].misc1;
29154 }
29155
29156 int32_t total = game->get_drupy()-price;
29157 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29158 game->set_drupy(game->get_drupy()-total);
29159
29160 //game->set_drupy(game->get_drupy()+price);
29161 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29162 game->change_maxarrows(10);
29163 game->set_arrows(game->get_maxarrows());
29164 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
29165 fadeclk=66;
29166 dismissmsg();
29167 clear_bitmap(pricesdisplaybuf);
29168 set_clip_state(pricesdisplaybuf, 1);
29169 // putscr(scrollbuf,0,0,tmpscr);
29170 verifyBothWeapons();
29171 break;
29172 }
29173
29174 case rSWINDLE:
29175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(items.spr(index)->id==iRupy)
29176 {
29177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
29178 return;
29179 11 int32_t tmpprice = -tmpscr[tmp].catchall;
29180 11 int32_t total = game->get_drupy()-tmpprice;
29181 11 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29182 11 game->set_drupy(game->get_drupy()-total);
29183 11 }
29184 else
29185 {
29186 if(game->get_maxlife()<=game->get_hp_per_heart())
29187 return;
29188
29189 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
29190 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
29191 }
29192
29193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29194 11 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
29195 11 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
29196 11 fadeclk=66;
29197 11 dismissmsg();
29198 11 clear_bitmap(pricesdisplaybuf);
29199 11 set_clip_state(pricesdisplaybuf, 1);
29200 // putscr(scrollbuf,0,0,tmpscr);
29201 11 break;
29202 }
29203 38 }
29204
29205 10846 void getitem(int32_t id, bool nosound, bool doRunPassive)
29206 {
29207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10846 times.
10846 if(unsigned(id) >= MAXITEMS)
29208 return;
29209
29210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10846 times.
10846 if (replay_is_active())
29211
1/2
✓ Branch 0 taken 10846 times.
✗ Branch 1 not taken.
10846 replay_step_comment(fmt::format("getitem {}", item_string[id]));
29212
29213
2/2
✓ Branch 0 taken 10836 times.
✓ Branch 1 taken 10 times.
10846 if(get_qr(qr_SCC_ITEM_COMBINES_ITEMS))
29214 {
29215 10 int32_t nextitem = -1;
29216 10 do
29217 {
29218 10 nextitem = -1;
29219
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
29220 // Item upgrade routine.
29221 {
29222
29223 for(int32_t i=0; i<MAXITEMS; i++)
29224 {
29225 // Find the item which is as close to this item's fam_type as possible.
29226 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
29227 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29228 {
29229 nextitem = i;
29230 }
29231 }
29232
29233 if(nextitem>-1)
29234 {
29235 id = nextitem;
29236 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
29237 break; //no looping
29238 }
29239 }
29240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 } while(nextitem > -1);
29241 10 }
29242
29243 10846 itemdata const& idat = itemsbuf[id&0xFF];
29244
29245 21692 bool equipment = idat.flags &
29246 10846 ((idat.family == itype_triforcepiece) ? ITEM_FLAG8 : ITEM_GAMEDATA);
29247
29248
2/2
✓ Branch 0 taken 9834 times.
✓ Branch 1 taken 1012 times.
10846 if(equipment)
29249 {
29250 // Fix boomerang sounds.
29251 1012 int32_t itemid = current_item_id(idat.family);
29252
29253
4/6
✓ Branch 0 taken 596 times.
✓ Branch 1 taken 416 times.
✓ Branch 2 taken 583 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1012 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_divineprotection
29254
5/6
✓ Branch 0 taken 583 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 581 times.
✓ Branch 5 taken 1 times.
583 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
29255 596 && sfx_allocated(itemsbuf[itemid].usesound)
29256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
596 && idat.usesound != itemsbuf[itemid].usesound)
29257 {
29258 stop_sfx(itemsbuf[itemid].usesound);
29259 cont_sfx(idat.usesound);
29260 }
29261
29262 1012 int32_t curitm = current_item_id(idat.family);
29263
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1012 if(!get_qr(qr_KEEPOLD_APPLIES_RETROACTIVELY)
29264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1012 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
29265 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
29266 {
29267 1012 game->set_item(id,true);
29268 1012 passiveitem_script(id, doRunPassive);
29269 1012 }
29270
29271
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 684 times.
1012 if(!(idat.flags & ITEM_KEEPOLD))
29272 {
29273
3/4
✓ Branch 0 taken 569 times.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 569 times.
684 if(!get_qr(qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
29274 {
29275 115 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
29276 115 }
29277 684 }
29278
29279 // NES consistency: replace all flying boomerangs with the current boomerang.
29280
2/2
✓ Branch 0 taken 982 times.
✓ Branch 1 taken 30 times.
1012 if(idat.family==itype_brang)
29281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<Lwpns.Count(); i++)
29282 {
29283 weapon *w = ((weapon*)Lwpns.spr(i));
29284
29285 if(w->id==wBrang)
29286 {
29287 w->LOADGFX(idat.wpn);
29288 }
29289 30 }
29290 1012 }
29291
29292
2/2
✓ Branch 0 taken 1732 times.
✓ Branch 1 taken 9114 times.
10846 if(idat.count!=-1)
29293 {
29294
2/2
✓ Branch 0 taken 8838 times.
✓ Branch 1 taken 276 times.
9114 if(idat.setmax)
29295 {
29296 // Bomb bags are a special case; they may be set not to increase super bombs
29297
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 268 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
276 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
29298 {
29299 int32_t max = game->get_maxbombs();
29300
29301 if(max<idat.max) max=idat.max;
29302
29303 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
29304 }
29305 else
29306 {
29307 276 int32_t max = game->get_maxcounter(idat.count);
29308
29309
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 197 times.
276 if(max<idat.max) max=idat.max;
29310
29311
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 109 times.
276 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
29312 }
29313 276 }
29314
29315 // Amount is an uint16_t, but the range is -9999 to 16383
29316 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
29317
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 8913 times.
9114 if(idat.amount&0x3FFF)
29318 {
29319
2/2
✓ Branch 0 taken 5627 times.
✓ Branch 1 taken 3286 times.
8913 if(idat.amount&0x8000)
29320 11254 game->set_dcounter(
29321
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5626 times.
5627 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29322 else
29323 {
29324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3286 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3286 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
29325 game->set_counter(0, idat.count);
29326 else
29327 // This is too confusing to try and change...
29328
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3286 times.
✓ Branch 2 taken 1494 times.
✓ Branch 3 taken 1792 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1494 times.
3286 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
29329 }
29330 8913 }
29331 9114 }
29332
29333
4/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 10587 times.
10846 if(idat.playsound&&!nosound)
29334 {
29335 10587 sfx(idat.playsound);
29336 10587 }
29337
29338 //add lower-level items
29339
2/2
✓ Branch 0 taken 10818 times.
✓ Branch 1 taken 28 times.
10846 if(idat.flags&ITEM_GAINOLD)
29340 {
29341
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 28 times.
52 for(int32_t i=idat.fam_type-1; i>0; i--)
29342 {
29343 24 int32_t potid = getItemID(itemsbuf, idat.family, i);
29344
29345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(potid != -1)
29346 {
29347 24 game->set_item(potid, true);
29348 24 }
29349 24 }
29350 28 }
29351
29352
11/14
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 9741 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 404 times.
✓ Branch 6 taken 53 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 59 times.
✓ Branch 9 taken 55 times.
✓ Branch 10 taken 31 times.
✓ Branch 11 taken 402 times.
✓ Branch 12 taken 50 times.
✓ Branch 13 taken 22 times.
10846 switch(idat.family)
29353 {
29354 case itype_itmbundle:
29355 {
29356 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29357 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29358 bool pscript = (idat.flags & ITEM_FLAG1);
29359 for(auto q = 0; q < 10; ++q)
29360 {
29361 if(unsigned(ids[q]) >= MAXITEMS) continue;
29362 if(pscript)
29363 collectitem_script(ids[q]);
29364 getitem(ids[q], true, true);
29365 }
29366 }
29367 break;
29368
29369 case itype_progressive_itm:
29370 {
29371 int32_t newid = get_progressive_item(idat);
29372 if(newid > -1)
29373 getitem(newid, nosound, true);
29374 }
29375 break;
29376
29377 case itype_bottlefill:
29378 {
29379 if(idat.misc1)
29380 {
29381 game->fillBottle(idat.misc1);
29382 }
29383 }
29384 break;
29385
29386 case itype_clock:
29387 {
29388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
404 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29389 break;
29390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 404 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
404 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
29391 break;
29392 404 setClock(watch=true);
29393
29394
2/2
✓ Branch 0 taken 206848 times.
✓ Branch 1 taken 404 times.
207252 for(int32_t i=0; i<eMAXGUYS; i++)
29395 206848 clock_zoras[i]=0;
29396
29397 404 clockclk=itemsbuf[id&0xFF].misc1;
29398 404 sfx(idat.usesound);
29399 }
29400 404 break;
29401
29402 case itype_lkey:
29403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
29404 53 break;
29405
29406 case itype_ring:
29407 case itype_magicring:
29408
6/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 1 times.
25 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29409 {
29410 24 ringcolor(false);
29411 24 }
29412 25 break;
29413
29414 case itype_whispring:
29415 {
29416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(idat.flags & ITEM_FLAG1)
29417 {
29418
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
29419
29420
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
29421 4 }
29422
29423
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(idat.power==0)
29424 {
29425 2 setSwordClk(0);
29426 2 setItemClk(0);
29427 2 }
29428
29429 4 break;
29430 }
29431
29432
29433 case itype_map:
29434 59 game->lvlitems[dlevel]|=liMAP;
29435 59 break;
29436
29437 case itype_compass:
29438 55 game->lvlitems[dlevel]|=liCOMPASS;
29439 55 break;
29440
29441 case itype_bosskey:
29442 31 game->lvlitems[dlevel]|=liBOSSKEY;
29443 31 break;
29444
29445 case itype_fairy:
29446
29447
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 274 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
402 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
29448
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 332 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
402 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
29449 402 break;
29450
29451 case itype_heartpiece:
29452 50 game->change_HCpieces(1);
29453
29454
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 11 times.
50 if(game->get_HCpieces()<game->get_hcp_per_hc())
29455 39 break;
29456
29457 11 game->set_HCpieces(0);
29458
29459 11 getitem(heart_container_id());
29460 11 break;
29461
29462 case itype_killem:
29463 {
29464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(idat.flags & ITEM_FLAG1) //Active use, not passive
29465 break;
29466 22 kill_em_all();
29467 22 sfx(idat.usesound);
29468 }
29469 22 break;
29470 }
29471
29472 10846 flushItemCache();
29473 10846 update_subscreens();
29474 10846 load_Sitems();
29475 10846 verifyBothWeapons();
29476 10846 }
29477
29478 void takeitem(int32_t id)
29479 {
29480 game->set_item(id, false);
29481 itemdata const& idat = itemsbuf[id];
29482
29483 /* Lower the counters! */
29484 if(idat.count!=-1)
29485 {
29486 if(idat.setmax)
29487 {
29488 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
29489 }
29490
29491 if(idat.amount&0x3FFF)
29492 {
29493 if(idat.amount&0x8000)
29494 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29495 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
29496 }
29497 }
29498
29499 switch(itemsbuf[id&0xFF].family)
29500 {
29501 // NES consistency: replace all flying boomerangs with the current boomerang.
29502 case itype_brang:
29503 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
29504 {
29505 weapon *w = ((weapon*)Lwpns.spr(i));
29506
29507 if(w->id==wBrang)
29508 {
29509 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
29510 }
29511 }
29512
29513 break;
29514
29515 case itype_itmbundle:
29516 {
29517 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
29518 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
29519 for(auto q = 0; q < 10; ++q)
29520 {
29521 if(unsigned(ids[q]) >= MAXITEMS) continue;
29522 takeitem(ids[q]);
29523 }
29524 }
29525 break;
29526
29527 case itype_progressive_itm:
29528 {
29529 int32_t newid = get_progressive_item(idat, true);
29530 if(newid > -1)
29531 takeitem(newid);
29532 }
29533 break;
29534
29535 case itype_heartpiece:
29536 if(game->get_maxlife()>game->get_hp_per_heart())
29537 {
29538 if(game->get_HCpieces()==0)
29539 {
29540 game->set_HCpieces(game->get_hcp_per_hc());
29541 takeitem(iHeartC);
29542 }
29543
29544 game->change_HCpieces(-1);
29545 }
29546 break;
29547
29548 case itype_map:
29549 game->lvlitems[dlevel]&=~liMAP;
29550 break;
29551
29552 case itype_compass:
29553 game->lvlitems[dlevel]&=~liCOMPASS;
29554 break;
29555
29556 case itype_bosskey:
29557 game->lvlitems[dlevel]&=~liBOSSKEY;
29558 break;
29559
29560 case itype_lkey:
29561 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
29562 break;
29563
29564 case itype_ring:
29565 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
29566 {
29567 ringcolor(false);
29568 }
29569 break;
29570 }
29571 }
29572
29573 7720 void post_item_collect()
29574 {
29575 7720 std::vector<int32_t> &ev = FFCore.eventData;
29576 7720 ev.clear();
29577
29578 7720 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
29579 7720 }
29580
29581 7771 void HeroClass::handle_triforce(int32_t id)
29582 {
29583
1/2
✓ Branch 0 taken 7771 times.
✗ Branch 1 not taken.
7771 if(unsigned(id) >= MAXITEMS)
29584 return;
29585 7771 itemdata const& itm = itemsbuf[id];
29586
2/3
✓ Branch 0 taken 7701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
7771 switch(itm.family)
29587 {
29588 case itype_itmbundle:
29589 {
29590 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
29591 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
29592 for(auto q = 0; q < 10; ++q)
29593 {
29594 if(unsigned(ids[q]) >= MAXITEMS) continue;
29595 handle_triforce(ids[q]);
29596 }
29597 }
29598 break;
29599 case itype_triforcepiece:
29600 {
29601
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 62 times.
70 if(itm.misc2>0)
29602 62 getTriforce(id); //small
29603 8 else getBigTri(id); //big
29604 }
29605 70 break;
29606 }
29607 7771 }
29608
29609 // Attempt to pick up an item. (-1 = check items touching Hero.)
29610 7253676 void HeroClass::checkitems(int32_t index)
29611 {
29612 7253676 int32_t tmp=currscr>=128?1:0;
29613
29614
2/2
✓ Branch 0 taken 1519 times.
✓ Branch 1 taken 7252157 times.
7253676 if(index==-1)
29615 {
29616
2/2
✓ Branch 0 taken 1495657 times.
✓ Branch 1 taken 7252157 times.
8747814 for(auto ind = items.Count()-1; ind >= 0; --ind)
29617 {
29618 1495657 item* itm = (item*)items.spr(ind);
29619
2/2
✓ Branch 0 taken 1495645 times.
✓ Branch 1 taken 12 times.
1495657 if(itm->get_forcegrab())
29620 {
29621 12 checkitems(ind);
29622 12 }
29623 1495657 }
29624
2/2
✓ Branch 0 taken 913855 times.
✓ Branch 1 taken 6338302 times.
7252157 if(diagonalMovement)
29625 {
29626 913855 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
29627 913855 }
29628 6338302 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
29629 7252157 }
29630
29631
2/2
✓ Branch 0 taken 58340 times.
✓ Branch 1 taken 7195336 times.
7253676 if(index==-1)
29632 7195336 return;
29633
29634 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
29635 // return;
29636 58340 item* ptr = (item*)items.spr(index);
29637 58340 int32_t pickup = ptr->pickup;
29638 58340 int8_t exstate = ptr->pickupexstate;
29639 58340 int32_t PriceIndex = ptr->PriceIndex;
29640 58340 int32_t id2 = ptr->id;
29641 58340 int32_t holdid = ptr->id;
29642 58340 int32_t pstr = ptr->pstring;
29643 58340 int32_t pstr_flags = ptr->pickup_string_flags;
29644 58340 int32_t linked_parent = ptr->linked_parent;
29645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58340 times.
58340 if(ptr->fallclk > 0) return; //Don't pick up a falling item
29646
29647
1/2
✓ Branch 0 taken 58340 times.
✗ Branch 1 not taken.
58340 if(itemsbuf[id2].family == itype_progressive_itm)
29648 {
29649 int32_t newid = get_progressive_item(itemsbuf[id2]);
29650 if(newid > -1)
29651 {
29652 id2 = newid;
29653 holdid = newid;
29654 pstr = itemsbuf[newid].pstring;
29655 pstr_flags = itemsbuf[newid].pickup_string_flags;
29656 }
29657 }
29658
29659
2/2
✓ Branch 0 taken 57455 times.
✓ Branch 1 taken 885 times.
58340 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
29660
29661
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 58338 times.
58340 if(bottledummy) //Dummy bullshit!
29662 {
29663
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!game->canFillBottle())
29664 return;
29665
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29666 {
29667 if(!current_item_power(itype_wallet))
29668 {
29669 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29670 int32_t tmpprice = -abs(prices[PriceIndex]);
29671 //game->change_drupy(-abs(prices[priceindex]));
29672 int32_t total = game->get_drupy()-tmpprice;
29673 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29674 game->set_drupy(game->get_drupy()-total);
29675 }
29676 else //infinite wallet
29677 {
29678 game->change_drupy(0);
29679 }
29680 }
29681 2 boughtsomething=true;
29682 //make the other shop items untouchable after
29683 //you buy something
29684 2 int32_t count = 0;
29685
29686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<3; i++)
29687 {
29688 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
29689 {
29690 ++count;
29691 }
29692 }
29693
29694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<items.Count(); i++)
29695 {
29696 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29697 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29698 }
29699
29700 2 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
29701 2 id2 = find_bottle_for_slot(slot);
29702 2 ptr->id = id2;
29703 2 pstr = 0;
29704 2 pickup |= ipHOLDUP;
29705 2 }
29706 else
29707 {
29708 58338 std::vector<int32_t> &ev = FFCore.eventData;
29709 58338 ev.clear();
29710 58338 ev.push_back(id2*10000);
29711 58338 ev.push_back(pickup*10000);
29712 58338 ev.push_back(pstr*10000);
29713 58338 ev.push_back(pstr_flags*10000);
29714 58338 ev.push_back(0);
29715 58338 ev.push_back(ptr->getUID());
29716 58338 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
29717 58338 ev.push_back(0);
29718
29719 58338 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
29720 58338 bool nullify = ev[4] != 0;
29721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58338 times.
58338 if(nullify) return;
29722 58338 id2 = ev[0]/10000;
29723 58338 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
29724 58338 pstr = ev[2] / 10000;
29725 58338 pstr_flags = ev[3] / 10000;
29726
29727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58338 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58338 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
29728 return; //No picking these up unless you have a bottle to fill!
29729
29730
5/6
✓ Branch 0 taken 55213 times.
✓ Branch 1 taken 3125 times.
✓ Branch 2 taken 48935 times.
✓ Branch 3 taken 6278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48935 times.
58338 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
29731
2/2
✓ Branch 0 taken 48806 times.
✓ Branch 1 taken 129 times.
48935 if(ptr->id!=iFairyMoving)
29732 // wait for it to stop flashing, doesn't check for other items yet
29733 48806 return;
29734
29735
2/2
✓ Branch 0 taken 9504 times.
✓ Branch 1 taken 28 times.
9532 if(pickup&ipENEMY) // item was being carried by enemy
29736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
56 if(more_carried_items()<=1) // 1 includes this own item.
29737 28 hasitem &= ~2;
29738
29739
2/2
✓ Branch 0 taken 1049 times.
✓ Branch 1 taken 8483 times.
9532 if(pickup&ipDUMMY) // dummy item (usually a rupee)
29740 {
29741
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 38 times.
1049 if(pickup&ipMONEY)
29742 38 dospecialmoney(index);
29743
29744 1049 return;
29745 }
29746
29747
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8483 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8483 if(get_qr(qr_HEARTSREQUIREDFIX) && !canget(id2))
29748 return;
29749
29750 8483 int32_t nextitem = -1;
29751 8483 do
29752 {
29753 8483 nextitem = -1;
29754
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 8469 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
8483 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
29755 // Item upgrade routine.
29756 {
29757
29758
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++)
29759 {
29760 // Find the item which is as close to this item's fam_type as possible.
29761
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
2560 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
29762
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
29763 {
29764 10 nextitem = i;
29765 10 }
29766 2560 }
29767
29768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nextitem>-1)
29769 {
29770 10 id2 = nextitem;
29771
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(get_qr(qr_ITEMCOMBINE_NEW_PSTR))
29772 {
29773 pstr = itemsbuf[id2].pstring;
29774 pstr_flags = itemsbuf[id2].pickup_string_flags;
29775 }
29776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
29777 10 break; //no looping
29778 }
29779 }
29780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8473 times.
8473 } while(nextitem > -1);
29781
29782
2/2
✓ Branch 0 taken 7598 times.
✓ Branch 1 taken 885 times.
8483 if(pickup&ipCHECK) // check restrictions
29783
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 664 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 107 times.
885 switch(tmpscr[tmp].room)
29784 {
29785 case rSP_ITEM: // special item
29786
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 19 times.
114 if(!canget(id2)) // These ones always need the Hearts Required check
29787 19 return;
29788
29789 95 break;
29790
29791 case rP_SHOP: // potion shop
29792
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
29793 93 return;
29794 [[fallthrough]];
29795 case rSHOP: // shop
29796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 678 times.
678 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
29797 {
29798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 678 times.
678 if(!current_item_power(itype_wallet))
29799 {
29800
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 78 times.
678 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
29801 78 int32_t tmpprice = -abs(prices[PriceIndex]);
29802 //game->change_drupy(-abs(prices[priceindex]));
29803 78 int32_t total = game->get_drupy()-tmpprice;
29804 78 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
29805 78 game->set_drupy(game->get_drupy()-total);
29806 78 }
29807 else //infinite wallet
29808 {
29809 game->change_drupy(0);
29810 }
29811 78 }
29812 78 boughtsomething=true;
29813 //make the other shop items untouchable after
29814 //you buy something
29815 78 int32_t count = 0;
29816
29817
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 78 times.
312 for(int32_t i=0; i<3; i++)
29818 {
29819
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 196 times.
234 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
29820 {
29821 196 ++count;
29822 196 }
29823 234 }
29824
29825
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 78 times.
352 for(int32_t i=0; i<items.Count(); i++)
29826 {
29827
4/4
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 118 times.
274 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
29828 118 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
29829 274 }
29830
29831 78 break;
29832 173 }
29833
29834
2/2
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 6876 times.
7771 if(pickup&ipONETIME) // set mITEM for one-time-only items
29835 {
29836 895 setmapflag(mITEM);
29837
29838 //Okay so having old source files is a godsend. You wanna know why?
29839 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
29840 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
29841 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
29842 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
29843 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
29844
29845 /*
29846 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
29847 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
29848
29849 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
29850 // What is etc?! We need to check for every valid state here. ~Gleeok
29851 if(get_qr(qr_ITEMPICKUPSETSBELOW))
29852 {
29853 // Most older quests need one-time-pickups to not remove special items, etc.
29854 if(tmpscr->room==rGRUMBLE)
29855 {
29856 setmapflag(mSPECIALITEM);
29857 }
29858 }
29859 */
29860 895 }
29861
2/2
✓ Branch 0 taken 6572 times.
✓ Branch 1 taken 304 times.
6876 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
29862
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 114 times.
304 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
29863
29864
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
7771 if(exstate > -1 && exstate < 32)
29865 {
29866 1 setxmapflag(1<<exstate);
29867 1 }
29868
29869
2/2
✓ Branch 0 taken 7770 times.
✓ Branch 1 taken 1 times.
7771 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
29870 {
29871
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
29872 1 hidden_entrance(0, true, false, -5);
29873 1 }
29874
29875 7771 collectitem_script(id2);
29876 7771 getitem(id2, false, true);
29877 }
29878
29879
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 7139 times.
7773 if(pickup&ipHOLDUP)
29880 {
29881 630 attackclk=0;
29882 630 reset_swordcharge();
29883
29884
3/4
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 623 times.
630 if(action!=swimming && !IsSideSwim())
29885 623 reset_hookshot();
29886
29887
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 186 times.
630 if(msg_onscreen)
29888 {
29889 186 dismissmsg();
29890 186 }
29891
29892 630 clear_bitmap(pricesdisplaybuf);
29893
29894
6/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 626 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 5 times.
631 if(get_qr(qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
29895
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
5 (get_qr(qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
29896 {
29897 628 fadeclk=66;
29898 628 }
29899
29900
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 626 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
632 if(id2!=iBombs || action==swimming || get_qr(qr_BOMBHOLDFIX))
29901 {
29902 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
29903
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 621 times.
630 if(action==swimming)
29904 {
29905 9 action=waterhold1; FFCore.setHeroAction(waterhold1);
29906 9 }
29907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
621 else if(IsSideSwim())
29908 {
29909 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
29910 }
29911 else
29912 {
29913 621 action=landhold1; FFCore.setHeroAction(landhold1);
29914 }
29915
29916
2/2
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 184 times.
630 if(ptr->twohand)
29917 {
29918
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 180 times.
184 if(action==waterhold1)
29919 {
29920 4 action=waterhold2; FFCore.setHeroAction(waterhold2);
29921 4 }
29922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 else if(action==sidewaterhold1)
29923 {
29924 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
29925 }
29926 else
29927 {
29928 180 action=landhold2; FFCore.setHeroAction(landhold2);
29929 }
29930 184 }
29931
29932 630 holdclk=130;
29933
29934 //restart music
29935
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 77 times.
630 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0)
29936 77 music_stop();
29937
29938 630 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
29939 630 freeze_guys=true;
29940 //show the info string
29941
29942
29943 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
29944
29945 630 int32_t shop_pstr = 0;
29946
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 91 times.
630 if (PriceIndex > -1)
29947 {
29948
2/3
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
91 switch(tmpscr[tmp].room)
29949 {
29950 case rSHOP:
29951 64 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
29952 64 break;
29953 case rBOTTLESHOP:
29954 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
29955 break;
29956 }
29957 91 }
29958
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
630 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
29959 {
29960 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
29961 {
29962 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
29963 }
29964 else pstr = 0;
29965 if(shop_pstr)
29966 {
29967 donewmsg(shop_pstr);
29968 enqueued_str = pstr;
29969 }
29970 else if(pstr)
29971 {
29972 donewmsg(pstr);
29973 }
29974 }
29975
29976 630 }
29977
29978
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 570 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
632 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
29979 {
29980 570 sfx(tmpscr[0].holdupsfx);
29981 570 }
29982
29983 632 ptr->set_forcegrab(false);
29984 632 items.del(index);
29985
29986
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 632 times.
756 for(int32_t i=0; i<Lwpns.Count(); i++)
29987 {
29988 124 weapon *w = (weapon*)Lwpns.spr(i);
29989
29990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(w->dragging==index)
29991 {
29992 w->dragging=-1;
29993 }
29994
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 else if(w->dragging>index)
29995 {
29996 w->dragging-=1;
29997 }
29998 124 }
29999
30000 // clear up shop stuff
30001
4/4
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 255 times.
632 if((isdungeon()==0)&&(index!=0))
30002 {
30003
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 62 times.
82 if(boughtsomething)
30004 {
30005 62 fadeclk=66;
30006
30007
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
62 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
30008 {
30009 62 items.del(0);
30010
30011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 for(int32_t i=0; i<Lwpns.Count(); i++)
30012 {
30013 weapon *w = (weapon*)Lwpns.spr(i);
30014
30015 if(w->dragging==0)
30016 {
30017 w->dragging=-1;
30018 }
30019 else if(w->dragging>0)
30020 {
30021 w->dragging-=1;
30022 }
30023 }
30024 62 }
30025 62 }
30026
30027
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(msg_onscreen)
30028 {
30029 dismissmsg();
30030 }
30031
30032 82 clear_bitmap(pricesdisplaybuf);
30033 82 set_clip_state(pricesdisplaybuf, 1);
30034 82 }
30035
30036 // items.del(index);
30037 632 }
30038 else
30039 {
30040 7139 ptr->set_forcegrab(false);
30041 7139 items.del(index);
30042
30043
2/2
✓ Branch 0 taken 6018 times.
✓ Branch 1 taken 7139 times.
13157 for(int32_t i=0; i<Lwpns.Count(); i++)
30044 {
30045 6018 weapon *w = (weapon*)Lwpns.spr(i);
30046
30047
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 5981 times.
6018 if(w->dragging==index)
30048 {
30049 37 w->dragging=-1;
30050 37 }
30051
1/2
✓ Branch 0 taken 5981 times.
✗ Branch 1 not taken.
5981 else if(w->dragging>index)
30052 {
30053 w->dragging-=1;
30054 }
30055 6018 }
30056
30057
2/2
✓ Branch 0 taken 7130 times.
✓ Branch 1 taken 9 times.
7139 if(msg_onscreen)
30058 {
30059 9 dismissmsg();
30060 9 }
30061
30062 //general item pickup message
30063 //show the info string
30064 //non-held
30065 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
30066
3/6
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 7007 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7139 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
30067
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7138 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7138 times.
7139 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
30068 {
30069
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
30070 {
30071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
30072 1 }
30073 else pstr = 0;
30074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
30075 {
30076 donewmsg(shop_pstr);
30077 enqueued_str = pstr;
30078 }
30079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
30080 {
30081 1 donewmsg(pstr);
30082 1 }
30083 1 }
30084
30085
30086 7139 clear_bitmap(pricesdisplaybuf);
30087 7139 set_clip_state(pricesdisplaybuf, 1);
30088 }
30089
30090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
7779 if(itemsbuf[id2].family==itype_triforcepiece
30091
4/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 7701 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 62 times.
7771 && itemsbuf[id2].misc2 <= 0 && linked_parent == eeGANON)
30092 {
30093 8 game->lvlitems[dlevel]|=liBOSS;
30094 8 }
30095 7771 handle_triforce(id2);
30096
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 7203 times.
7771 if(!holdclk)
30097 7203 post_item_collect();
30098 7253674 }
30099
30100 211 void HeroClass::StartRefill(int32_t refillWhat)
30101 {
30102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
211 if(!refilling)
30103 {
30104 211 refillclk=21;
30105 211 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30106 211 sfx(WAV_REFILL,128,true);
30107 211 refilling=refillWhat;
30108
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 6 times.
211 if(FFCore.quest_format[vZelda] < 0x255)
30109 {
30110 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
30111 //I attempted to change this check to a quest rule, but here's the issue: this affects
30112 //triforces and potions as well, not just fairy flags. This means that having a compat rule
30113 //would result in a rule that is checked by default for every tileset or quest made before
30114 //2.55, one in a place most people won't check. That means that if they were to go to use
30115 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
30116 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
30117 //"go through the compat rules and turn them all off", so this remains a version check instead
30118 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
30119 205 Start250Refill(refillWhat);
30120 205 }
30121 else //use 2.55+ behavior
30122 {
30123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
30124 {
30125 if(itemsbuf[refill_why].family==itype_potion)
30126 {
30127 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
30128 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
30129 }
30130 else if(itemsbuf[refill_why].family==itype_triforcepiece)
30131 {
30132 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
30133 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
30134 }
30135 }
30136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
30137 {
30138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_qr(qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
30139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_qr(qr_ITEMBUBBLE))itemclk=0;
30140 6 }
30141 }
30142 211 }
30143 211 }
30144
30145 205 void HeroClass::Start250Refill(int32_t refillWhat)
30146 {
30147
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 if(!refilling)
30148 {
30149 refillclk=21;
30150 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
30151 sfx(WAV_REFILL,128,true);
30152 refilling=refillWhat;
30153
30154 if(refill_why>=0) // Item index
30155 {
30156 if((itemsbuf[refill_why].family==itype_potion)&&(!get_qr(qr_NONBUBBLEMEDICINE)))
30157 {
30158 swordclk=0;
30159 verifyAWpn();
30160 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30161 }
30162
30163 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_qr(qr_NONBUBBLETRIFORCE)))
30164 {
30165 swordclk=0;
30166 verifyAWpn();
30167 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30168 }
30169 }
30170 else if((refill_why==REFILL_FAIRY)&&(!get_qr(qr_NONBUBBLEFAIRIES)))
30171 {
30172 swordclk=0;
30173 verifyAWpn();
30174 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
30175 }
30176 }
30177 205 }
30178
30179 231504 bool HeroClass::refill()
30180 {
30181
4/4
✓ Branch 0 taken 17689 times.
✓ Branch 1 taken 213815 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 17053 times.
231504 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
30182 {
30183 214451 return false;
30184 }
30185
30186 17053 ++refillclk;
30187 17053 int32_t speed = get_qr(qr_FASTFILL) ? 6 : 22;
30188 17053 int32_t refill_heart_stop=game->get_maxlife();
30189 17053 int32_t refill_magic_stop=game->get_maxmagic();
30190
30191
4/4
✓ Branch 0 taken 8377 times.
✓ Branch 1 taken 8676 times.
✓ Branch 2 taken 3422 times.
✓ Branch 3 taken 4955 times.
17053 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
30192 {
30193
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
30194
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
30195 4955 }
30196
30197
2/2
✓ Branch 0 taken 15231 times.
✓ Branch 1 taken 1822 times.
17053 if(refillclk%speed == 0)
30198 {
30199 // game->life&=0xFFC;
30200
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 866 times.
1822 switch(refill_what)
30201 {
30202 case REFILL_LIFE:
30203
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 914 times.
956 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30204
30205
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 830 times.
956 if(game->get_life()>=refill_heart_stop)
30206 {
30207 126 game->set_life(refill_heart_stop);
30208 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30209
2/2
✓ Branch 0 taken 32256 times.
✓ Branch 1 taken 126 times.
32382 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30210 {
30211
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 32130 times.
32256 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30212
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 32129 times.
32130 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30213 32129 stop_sfx(q);
30214 32129 }
30215 126 sfx(QMisc.miscsfx[sfxREFILL]);
30216 126 refilling=REFILL_NONE;
30217 126 return false;
30218 }
30219
30220 830 break;
30221
30222 case REFILL_MAGIC:
30223 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30224
30225 if(game->get_magic()>=refill_magic_stop)
30226 {
30227 game->set_magic(refill_magic_stop);
30228 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30229 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30230 {
30231 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30232 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30233 stop_sfx(q);
30234 }
30235 sfx(QMisc.miscsfx[sfxREFILL]);
30236 refilling=REFILL_NONE;
30237 return false;
30238 }
30239
30240 break;
30241
30242 case REFILL_ALL:
30243
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 799 times.
866 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
30244
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 30 times.
866 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
30245
30246
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 19 times.
866 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
30247 {
30248 85 game->set_life(refill_heart_stop);
30249 85 game->set_magic(refill_magic_stop);
30250 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
30251
2/2
✓ Branch 0 taken 21760 times.
✓ Branch 1 taken 85 times.
21845 for ( int32_t q = 0; q < WAV_COUNT; q++ )
30252 {
30253
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 21675 times.
21760 if ( q == (int32_t)tmpscr->oceansfx ) continue;
30254
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 21656 times.
21675 if ( q == (int32_t)tmpscr->bosssfx ) continue;
30255 21656 stop_sfx(q);
30256 21656 }
30257 85 sfx(QMisc.miscsfx[sfxREFILL]);
30258 85 refilling=REFILL_NONE;
30259 85 return false;
30260 }
30261
30262 781 break;
30263 }
30264 1611 }
30265
30266 16842 return true;
30267 231504 }
30268
30269 62 void HeroClass::getTriforce(int32_t id2)
30270 {
30271
30272 PALETTE flash_pal;
30273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
30274
30275
2/2
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 62 times.
15934 for(int32_t i=0; i<256; i++)
30276 {
30277
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 7168 times.
15872 flash_pal[i] = get_qr(qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
30278 15872 }
30279
30280
30281
30282 //get rid off all sprites but Hero
30283 62 guys.clear();
30284 62 items.clear();
30285 62 Ewpns.clear();
30286 62 Lwpns.clear();
30287 62 Sitems.clear();
30288 62 chainlinks.clear();
30289
30290 //decorations.clear();
30291
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 17 times.
62 if(!COOLSCROLL)
30292 {
30293 17 show_subscreen_items=false;
30294 17 }
30295
30296 62 sfx(itemsbuf[id2].playsound);
30297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
30298
30299 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
30300
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
30301 {
30302 uint8_t playwav = itemsbuf[id2].misc3;
30303 //zprint2("playwav is: %d\n", playwav);
30304 sfx(playwav);
30305
30306 }
30307
30308 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
30309 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
30310 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
30311 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
30312 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
30313 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
30314 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
30315
30316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
30317 {
30318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(itemsbuf[id2].misc1)
30319 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
30320 else
30321 62 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
30322 62 }
30323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30324 {
30325 62 game->lvlitems[dlevel]|=liTRIFORCE;
30326 62 }
30327
30328 62 int32_t f=0;
30329 62 int32_t x2=0;
30330 62 int32_t curtain_x=0;
30331 62 int32_t c=0;
30332
30333 62 do
30334 {
30335
30336
30337
1/2
✓ Branch 0 taken 33066 times.
✗ Branch 1 not taken.
33066 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
30338 {
30339 if ( itemsbuf[id2].script )
30340 {
30341 if ( !FFCore.doscript(ScriptType::Item, id2) )
30342 {
30343 int i = id2;
30344 FFCore.reset_script_engine_data(ScriptType::Item, i);
30345 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
30346 FFCore.deallocateAllArrays(ScriptType::Item, i);
30347 }
30348 else
30349 {
30350 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
30351 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
30352 }
30353 }
30354 }
30355 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
30356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33066 times.
33066 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
30357 {
30358 return;
30359 }
30360
2/2
✓ Branch 0 taken 33004 times.
✓ Branch 1 taken 62 times.
33066 if(f==40)
30361 {
30362 62 actiontype oldaction = action;
30363 62 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
30364 62 action=oldaction; // have to reset this flag
30365 62 FFCore.setHeroAction(oldaction);
30366 62 }
30367
30368
30369
4/4
✓ Branch 0 taken 30586 times.
✓ Branch 1 taken 2480 times.
✓ Branch 2 taken 27610 times.
✓ Branch 3 taken 2976 times.
33066 if(f>=40 && f<88)
30370 {
30371
2/2
✓ Branch 0 taken 1632 times.
✓ Branch 1 taken 1344 times.
2976 if(get_qr(qr_FADE))
30372 {
30373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1632 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1632 if (!flash_reduction_enabled() && (f&7) == 0)
30374 {
30375 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
30376 refreshpal=true;
30377 }
30378
30379
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 408 times.
1632 if((f&3)==2)
30380 {
30381 408 loadpalset(0,0);
30382 408 loadpalset(1,1);
30383 408 loadpalset(5,5);
30384
30385
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 12 times.
408 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30386 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
30387 408 }
30388 1632 }
30389 else
30390 {
30391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1344 if(!flash_reduction_enabled() && (f&7) == 0)
30392 {
30393 for(int32_t cs2=2; cs2<5; cs2++)
30394 {
30395 for(int32_t i=1; i<16; i++)
30396 {
30397 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
30398 }
30399 }
30400
30401 refreshpal=true;
30402 }
30403
30404
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
30405 {
30406
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
30407 else loadlvlpal(0xB);
30408
30409 168 loadpalset(5,5);
30410 168 }
30411 }
30412 2976 }
30413
30414
30415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33066 times.
33066 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
30416 {
30417
2/2
✓ Branch 0 taken 33004 times.
✓ Branch 1 taken 62 times.
33066 if(f==refill_frame)
30418 {
30419 62 refill_what=REFILL_ALL;
30420 62 refill_why=id2;
30421 62 StartRefill(REFILL_ALL);
30422 62 refill();
30423 62 }
30424
30425
2/2
✓ Branch 0 taken 29698 times.
✓ Branch 1 taken 3368 times.
33066 if(f==(refill_frame+1))
30426 {
30427
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 3306 times.
3368 if(refill())
30428 {
30429 3306 --f;
30430 3306 }
30431 3368 }
30432 33066 }
30433
30434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33066 times.
33066 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
30435 {
30436
4/4
✓ Branch 0 taken 16864 times.
✓ Branch 1 taken 16202 times.
✓ Branch 2 taken 11904 times.
✓ Branch 3 taken 4960 times.
33066 if(f>=208 && f<288)
30437 {
30438 4960 ++x2;
30439
30440
3/3
✓ Branch 0 taken 1984 times.
✓ Branch 1 taken 1984 times.
✓ Branch 2 taken 992 times.
4960 switch(++c)
30441 {
30442 case 5:
30443 992 c=0;
30444 [[fallthrough]];
30445 case 0:
30446 case 2:
30447 case 3:
30448 2976 ++x2;
30449 2976 break;
30450 }
30451 4960 }
30452
30453 33066 do_dcounters();
30454
30455
2/2
✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 21162 times.
33066 if(f<288)
30456 {
30457 21162 curtain_x=x2&0xF8;
30458 21162 draw_screen_clip_rect_x1=curtain_x;
30459 21162 draw_screen_clip_rect_x2=255-curtain_x;
30460 21162 draw_screen_clip_rect_y1=0;
30461 21162 draw_screen_clip_rect_y2=223;
30462 //draw_screen(tmpscr);
30463 21162 }
30464 33066 }
30465
30466 33066 draw_screen(tmpscr);
30467 //this causes bugs
30468 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
30469 //so this is not necessary -DD
30470 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,false);
30471
30472 //Run Triforce Script
30473 33066 advanceframe(true);
30474 33066 ++f;
30475
2/2
✓ Branch 0 taken 33004 times.
✓ Branch 1 taken 62 times.
66132 }
30476 while
30477 (
30478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33066 times.
33066 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
30479
4/6
✓ Branch 0 taken 4526 times.
✓ Branch 1 taken 28540 times.
✓ Branch 2 taken 4526 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4526 times.
33066 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
30480
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4526 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4380 times.
✓ Branch 7 taken 146 times.
9052 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
30481 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
30482 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
30483 // value doesn't matter.
30484
2/4
✓ Branch 0 taken 4380 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4526 times.
4526 || (replay_is_active() && f < 480) )
30485 ); // 800 may not be just right, but it works
30486
30487 62 action=none; FFCore.setHeroAction(none);
30488 62 holdclk=0;
30489 62 draw_screen_clip_rect_x1=0;
30490 62 draw_screen_clip_rect_x2=255;
30491 62 draw_screen_clip_rect_y1=0;
30492 62 draw_screen_clip_rect_y2=223;
30493 62 show_subscreen_items=true;
30494
30495 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
30496 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
30497
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 1 times.
62 if((itemsbuf[id2].flags & ITEM_FLAG1) && ( get_qr(qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
30498 {
30499 61 sdir=dir;
30500 61 dowarp(1,0); //side warp
30501 61 }
30502 else
30503 {
30504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
30505 }
30506 62 }
30507
30508 8991 void red_shift()
30509 {
30510 8991 int32_t tnum=176;
30511
30512 // set up the new palette
30513
2/2
✓ Branch 0 taken 287712 times.
✓ Branch 1 taken 8991 times.
296703 for(int32_t i=CSET(2); i < CSET(4); i++)
30514 {
30515 287712 int32_t r = (i-CSET(2)) << 1;
30516 287712 RAMpal[i+tnum].r = r;
30517 287712 RAMpal[i+tnum].g = r >> 3;
30518 287712 RAMpal[i+tnum].b = r >> 4;
30519 287712 }
30520
30521 // color scale the game screen
30522
2/2
✓ Branch 0 taken 1510488 times.
✓ Branch 1 taken 8991 times.
1519479 for(int32_t y=0; y<168; y++)
30523 {
30524
2/2
✓ Branch 0 taken 386684928 times.
✓ Branch 1 taken 1510488 times.
388195416 for(int32_t x=0; x<256; x++)
30525 {
30526 386684928 int32_t c = framebuf->line[y+playing_field_offset][x];
30527
2/2
✓ Branch 0 taken 354968074 times.
✓ Branch 1 taken 31716854 times.
386684928 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30528
2/2
✓ Branch 0 taken 386663283 times.
✓ Branch 1 taken 21645 times.
386684928 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
30529 386684928 }
30530 1510488 }
30531
30532 8991 refreshpal = true;
30533 8991 }
30534
30535
30536
30537 void setup_red_screen_old()
30538 {
30539 clear_bitmap(framebuf);
30540 rectfill(scrollbuf, 0, 0, 255, 167, 0);
30541
30542 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
30543
30544 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
30545
30546 if(lenscheck(tmpscr,0)) putscr(scrollbuf, 0, 0, tmpscr);
30547 putscrdoors(scrollbuf,0,0,tmpscr);
30548 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30549 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
30550
30551 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
30552
30553 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
30554 {
30555 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
30556 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
30557 {
30558 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
30559 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
30560 }
30561 }
30562
30563 if(!(msg_bg_display_buf->clip))
30564 {
30565 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30566 }
30567
30568 if(!(msg_portrait_display_buf->clip))
30569 {
30570 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30571 }
30572
30573 if(!(msg_txt_display_buf->clip))
30574 {
30575 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
30576 }
30577
30578 if(!(pricesdisplaybuf->clip))
30579 {
30580 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
30581 }
30582
30583 //red shift
30584 // color scale the game screen
30585 for(int32_t y=0; y<168; y++)
30586 {
30587 for(int32_t x=0; x<256; x++)
30588 {
30589 int32_t c = framebuf->line[y+playing_field_offset][x];
30590 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30591 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
30592 }
30593 }
30594
30595 // Hero->draw(framebuf);
30596 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
30597
30598 clear_bitmap(framebuf);
30599
30600 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
30601 && tmpscr->layermap[3]==0
30602 && tmpscr->layermap[4]==0
30603 && tmpscr->layermap[5]==0
30604 && !overheadcombos(tmpscr)))
30605 {
30606 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
30607
30608 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
30609 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
30610 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
30611 {
30612 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
30613 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
30614 }
30615 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
30616 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
30617
30618 //do an AND masked blit for messages on top of layers
30619 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
30620 {
30621 BITMAP* subbmp = create_bitmap_ex(8,256,168);
30622 clear_bitmap(subbmp);
30623 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
30624 {
30625 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
30626 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
30627 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
30628 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
30629 }
30630 for(int32_t y=0; y<168; y++)
30631 {
30632 for(int32_t x=0; x<256; x++)
30633 {
30634 int32_t c1 = framebuf->line[y+playing_field_offset][x];
30635 int32_t c2 = subbmp->line[y][x];
30636 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
30637
30638 if(c1 && c3)
30639 {
30640 framebuf->line[y+playing_field_offset][x] = c3;
30641 }
30642 else if(c1 && c2)
30643 {
30644 framebuf->line[y+playing_field_offset][x] = c2;
30645 }
30646 }
30647 }
30648 destroy_bitmap(subbmp);
30649 }
30650
30651 //red shift
30652 // color scale the game screen
30653 for(int32_t y=0; y<168; y++)
30654 {
30655 for(int32_t x=0; x<256; x++)
30656 {
30657 int32_t c = framebuf->line[y+playing_field_offset][x];
30658 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
30659 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
30660 }
30661 }
30662 }
30663
30664 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
30665
30666 // set up the new palette
30667 for(int32_t i=CSET(2); i < CSET(4); i++)
30668 {
30669 int32_t r = (i-CSET(2)) << 1;
30670 RAMpal[i].r = r;
30671 RAMpal[i].g = r >> 3;
30672 RAMpal[i].b = r >> 4;
30673 }
30674
30675 refreshpal = true;
30676 }
30677
30678
30679
30680 60 void slide_in_color(int32_t color)
30681 {
30682
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
30683 {
30684 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
30685 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
30686 300 RAMpal[CSET(2)+i] = NESpal(color);
30687 300 }
30688
30689 60 refreshpal=true;
30690 60 }
30691
30692
30693 93 void HeroClass::heroDeathAnimation()
30694 {
30695 93 int32_t f=0;
30696 93 int32_t deathclk=0,deathfrm=0;
30697
30698 93 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
30699
30700 93 kill_sfx(); //call before the onDeath script.
30701
30702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(!debug_enabled)
30703 {
30704 93 Paused=false;
30705 93 }
30706
30707 /*
30708 game->set_deaths(zc_min(game->get_deaths()+1,999));
30709 dir=down;
30710 music_stop();
30711
30712 attackclk=hclk=superman=0;
30713 scriptcoldet = 1;
30714
30715 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30716
30717
30718
30719 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30720 quakeclk=wavy=0;
30721
30722 //in original Z1, Hero marker vanishes at death.
30723 //code in subscr.cpp, put_passive_subscr checks the following value.
30724 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30725 //Also, subscreen is static after death in Z1.
30726 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30727 QMisc.colors.hero_dot = 255;
30728 //doesn't work
30729 //scrollbuf is tampered with by draw_screen()
30730 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30731 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30732 clear_bitmap(subscrbmp);
30733 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, false, sspUP);
30734 QMisc.colors.hero_dot = tmp_hero_dot;
30735 */
30736 93 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
30737 93 clear_bitmap(subscrbmp);
30738 //get rid off all sprites but Hero
30739 93 guys.clear();
30740 93 items.clear();
30741 93 Ewpns.clear();
30742 93 Lwpns.clear();
30743 93 Sitems.clear();
30744 93 chainlinks.clear();
30745 93 decorations.clear();
30746 93 Playing = false;
30747
30748
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
30749 93 dir=down;
30750 93 music_stop();
30751
30752 93 attackclk=hclk=superman=0;
30753 93 scriptcoldet = 1;
30754
30755
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 93 times.
3069 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
30756
30757
30758
30759 93 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
30760 93 quakeclk=wavy=0;
30761
30762 //in original Z1, Hero marker vanishes at death.
30763 //code in subscr.cpp, put_passive_subscr checks the following value.
30764 //color 255 is a GUI color, so quest makers shouldn't be using this value.
30765 //Also, subscreen is static after death in Z1.
30766 93 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
30767 93 QMisc.colors.hero_dot = 255;
30768 //doesn't work
30769 //scrollbuf is tampered with by draw_screen()
30770 //put_passive_subscr(scrollbuf, 256, passive_subscreen_offset, false, false);//save this and reuse it.
30771
30772 93 put_passive_subscr(subscrbmp, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
30773 //Don't forget passive subscreen scripts!
30774
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
30775 {
30776 script_drawing_commands.Clear(); //We only want draws from this script
30777 if(DMaps[currdmap].passive_sub_script != 0)
30778 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
30779 if (FFCore.waitdraw(ScriptType::PassiveSubscreen) && DMaps[currdmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::PassiveSubscreen))
30780 {
30781 ZScriptVersion::RunScript(ScriptType::PassiveSubscreen, DMaps[currdmap].passive_sub_script, currdmap);
30782 FFCore.waitdraw(ScriptType::PassiveSubscreen) = false;
30783 }
30784 BITMAP* tmp = framebuf;
30785 framebuf = subscrbmp; //Hack; force draws to subscrbmp
30786 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
30787 framebuf = tmp;
30788 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
30789 }
30790 93 QMisc.colors.hero_dot = tmp_hero_dot;
30791 93 bool clearedit = false;
30792 93 do
30793 {
30794
2/2
✓ Branch 0 taken 23622 times.
✓ Branch 1 taken 9207 times.
32829 if(f<254)
30795 {
30796
2/2
✓ Branch 0 taken 20553 times.
✓ Branch 1 taken 3069 times.
23622 if(f<=32)
30797 {
30798 3069 hclk=(32-f);
30799 3069 }
30800
30801
4/4
✓ Branch 0 taken 17856 times.
✓ Branch 1 taken 5766 times.
✓ Branch 2 taken 10788 times.
✓ Branch 3 taken 7068 times.
23622 if(f>=62 && f<138)
30802 {
30803
5/5
✓ Branch 0 taken 5580 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 372 times.
✓ Branch 3 taken 372 times.
✓ Branch 4 taken 372 times.
7068 switch((f-62)%20)
30804 {
30805 case 0:
30806 372 dir=right;
30807 372 break;
30808
30809 case 5:
30810 372 dir=up;
30811 372 break;
30812
30813 case 10:
30814 372 dir=left;
30815 372 break;
30816
30817 case 15:
30818 372 dir=down;
30819 372 break;
30820 }
30821
30822 7068 herostep();
30823 7068 }
30824
30825
4/4
✓ Branch 0 taken 5580 times.
✓ Branch 1 taken 18042 times.
✓ Branch 2 taken 4278 times.
✓ Branch 3 taken 1302 times.
23622 if(f>=194 && f<208)
30826 {
30827
2/2
✓ Branch 0 taken 1209 times.
✓ Branch 1 taken 93 times.
1302 if(f==194)
30828 {
30829 93 action=dying;
30830 93 FFCore.setHeroAction(dying);
30831 93 }
30832
30833 1302 extend = 0;
30834 1302 cs = wpnsbuf[spr_death].csets&15;
30835 1302 tile = wpnsbuf[spr_death].tile;
30836
1/2
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
1302 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
30837 {
30838 tile += deathfrm;
30839 f = 206;
30840 if(++deathclk >= wpnsbuf[spr_death].speed)
30841 {
30842 deathclk=0;
30843 if(++deathfrm >= wpnsbuf[spr_death].frames)
30844 {
30845 f = 208;
30846 deathfrm = 0;
30847 }
30848 }
30849 }
30850
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 392 times.
1302 else if(BSZ)
30851 {
30852 910 tile += (f-194)/3;
30853 910 }
30854
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 112 times.
392 else if(f>=204)
30855 {
30856 112 ++tile;
30857 112 }
30858 1302 }
30859
30860
2/2
✓ Branch 0 taken 23529 times.
✓ Branch 1 taken 93 times.
23622 if(f==208)
30861 {
30862
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if ( dontdraw < 2 ) { dontdraw = 1; }
30863 93 }
30864
2/2
✓ Branch 0 taken 20574 times.
✓ Branch 1 taken 3048 times.
23622 if(get_qr(qr_FADE))
30865 {
30866
2/2
✓ Branch 0 taken 13770 times.
✓ Branch 1 taken 6804 times.
20574 if(f < 170)
30867 {
30868
2/2
✓ Branch 0 taken 8910 times.
✓ Branch 1 taken 4860 times.
13770 if(f<60)
30869 {
30870 4860 draw_screen(tmpscr);
30871 //reuse our static subscreen
30872 4860 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
30873 4860 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30874 4860 }
30875
30876
2/2
✓ Branch 0 taken 13689 times.
✓ Branch 1 taken 81 times.
13770 if(f==60)
30877 {
30878 81 red_shift();
30879 81 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30880 81 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30881 81 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30882
30883
2/2
✓ Branch 0 taken 20736 times.
✓ Branch 1 taken 81 times.
20817 for(int32_t q=0; q<PAL_SIZE; q++)
30884 {
30885 20736 trans_table2.data[0][q] = q;
30886 20736 trans_table2.data[q][q] = q;
30887 20736 }
30888 81 }
30889
30890
3/4
✓ Branch 0 taken 8910 times.
✓ Branch 1 taken 4860 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8910 times.
13770 if(f>=60 && f<=169)
30891 {
30892 8910 draw_screen(tmpscr);
30893 //reuse our static subscreen
30894 8910 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30895 8910 red_shift();
30896
30897 8910 }
30898
30899
3/4
✓ Branch 0 taken 2511 times.
✓ Branch 1 taken 11259 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2511 times.
13770 if(f>=139 && f<=169)//fade from red to black
30900 {
30901 2511 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
30902 2511 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
30903 2511 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
30904 2511 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
30905
30906
2/2
✓ Branch 0 taken 642816 times.
✓ Branch 1 taken 2511 times.
645327 for(int32_t q=0; q<PAL_SIZE; q++)
30907 {
30908 642816 trans_table2.data[0][q] = q;
30909 642816 trans_table2.data[q][q] = q;
30910 642816 }
30911
30912 2511 refreshpal=true;
30913 2511 }
30914 13770 }
30915 else //f>=170
30916 {
30917
2/2
✓ Branch 0 taken 6723 times.
✓ Branch 1 taken 81 times.
6804 if(f==170)//make Hero grayish
30918 {
30919 81 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
30920
30921
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 81 times.
1377 for(int32_t i=CSET(6); i < CSET(7); i++)
30922 {
30923 1296 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
30924 1296 RAMpal[i] = _RGB(g,g,g);
30925 1296 }
30926
30927 81 refreshpal = true;
30928 81 }
30929
30930 //draw only hero. otherwise black layers might cover him.
30931 6804 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
30932 6804 draw(framebuf);
30933 6804 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
30934 }
30935 20574 }
30936 else //!qr_FADE
30937 {
30938
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
30939 {
30940
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
30941 1152 tmpscr->cset[i] = 3;
30942
30943
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30944
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2 times.
74 if(tmpscr->layermap[j]>0)
30945
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
30946 194 tmpscr2[j].cset[i] = 3;
30947 12 }
30948
30949
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
30950 {
30951
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
30952 960 tmpscr->cset[i] = 3;
30953
30954
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30955
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2 times.
74 if(tmpscr->layermap[j]>0)
30956
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
30957 162 tmpscr2[j].cset[i] = 3;
30958 12 }
30959
30960
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
30961 {
30962
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
30963 {
30964 2112 tmpscr->cset[i] = 2;
30965 2112 }
30966
30967
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
30968
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 2 times.
74 if(tmpscr->layermap[j]>0)
30969
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
30970 354 tmpscr2[j].cset[i] = 2;
30971
30972
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
30973 {
30974 60 RAMpal[CSET(2)+i] = NESpal(0x17);
30975 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
30976 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
30977 60 }
30978
30979 12 refreshpal=true;
30980 12 }
30981
30982
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
30983 12 slide_in_color(0x06);
30984
30985
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
30986 12 slide_in_color(0x07);
30987
30988
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
30989 12 slide_in_color(0x0F);
30990
30991
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
30992 {
30993 12 slide_in_color(0x0F);
30994 12 slide_in_color(0x0F);
30995 12 }
30996
30997
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
30998 {
30999
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
31000 {
31001 60 RAMpal[CSET(6)+i] = NESpal(0x10);
31002 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
31003 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
31004 60 refreshpal = true;
31005 60 }
31006 12 }
31007
31008
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
31009 {
31010 2028 draw_screen(tmpscr);
31011 //reuse our static subscreen
31012 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31013 2028 }
31014 else
31015 {
31016 //draw only hero. otherwise black layers might cover him.
31017 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
31018 1020 draw(framebuf);
31019 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31020 }
31021 }
31022 23622 }
31023
31024
2/2
✓ Branch 0 taken 8928 times.
✓ Branch 1 taken 279 times.
9207 else if(f<350)//draw 'GAME OVER' text
31025 {
31026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8928 if(get_qr(qr_INSTANT_RESPAWN) && !get_qr(qr_INSTANT_CONTINUE))
31027 {
31028 Quit = qRELOAD;
31029 skipcont = 1;
31030 clear_bitmap(framebuf);
31031 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31032 }
31033
2/4
✓ Branch 0 taken 8928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8928 times.
✗ Branch 3 not taken.
8928 else if(!get_qr(qr_INSTANT_RESPAWN) && get_qr(qr_INSTANT_CONTINUE))
31034 {
31035 Quit = qCONT;
31036 skipcont = 1;
31037 clear_bitmap(framebuf);
31038 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31039 }
31040 else
31041 {
31042 8928 clear_a5_bmp(rti_infolayer.bitmap);
31043 8928 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
31044 8928 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
31045 8928 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
31046 }
31047 8928 }
31048 else
31049 {
31050 279 clear_bitmap(framebuf);
31051 }
31052
31053 //SFX... put them all here
31054
4/4
✓ Branch 0 taken 32550 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 93 times.
32829 switch(f)
31055 {
31056 case 0:
31057 93 sfx(getHurtSFX(),pan(x.getInt()));
31058 93 break;
31059 //Death sound.
31060 case 60:
31061 93 sfx(WAV_SPIRAL);
31062 93 break;
31063 //Message sound.
31064 case 194:
31065 93 sfx(WAV_MSG);
31066 93 break;
31067 }
31068 //adv:
31069 32829 clear_darkroom_bitmaps();
31070 32829 advanceframe(true);
31071 32829 ++f;
31072
2/2
✓ Branch 0 taken 32736 times.
✓ Branch 1 taken 93 times.
65658 }
31073
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 32736 times.
32829 while(f<353 && !Quit);
31074
31075 93 destroy_bitmap(subscrbmp);
31076 93 action=none; FFCore.setHeroAction(none);
31077
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if ( dontdraw < 2 ) { dontdraw=0; }
31078 93 }
31079
31080
31081 14 void HeroClass::ganon_intro()
31082 {
31083 /*
31084 ************************
31085 * GANON INTRO SEQUENCE *
31086 ************************
31087 -25 DOT updates
31088 -24 HERO in
31089 0 TRIFORCE overhead - code begins at this point (f == 0)
31090 47 GANON in
31091 58 LIGHT step
31092 68 LIGHT step
31093 78 LIGHT step
31094 255 TRIFORCE out
31095 256 TRIFORCE in
31096 270 TRIFORCE out
31097 271 GANON out, HERO face up
31098 */
31099 14 loaded_guys=true;
31100 14 loaditem();
31101
31102
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10 times.
14 if(game->lvlitems[dlevel]&liBOSS)
31103 {
31104 4 return;
31105 }
31106
31107 10 dir=down;
31108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if ( !isSideViewHero() )
31109 {
31110 10 fall = 0; //Fix midair glitch on holding triforce. -Z
31111 10 fakefall = 0;
31112 10 z = 0;
31113 10 fakez = 0;
31114 10 }
31115 10 action=landhold2; FFCore.setHeroAction(landhold2);
31116 10 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
31117 //not good, as this only returns the highest level that Hero possesses. -DD
31118 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
31119
31120
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2410 times.
✓ Branch 2 taken 2410 times.
✓ Branch 3 taken 10 times.
2420 for(int32_t f=0; f<271 && !Quit; f++)
31121 {
31122
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
2410 if(f==47)
31123 {
31124 10 music_stop();
31125 10 stop_sfx(WAV_ROAR);
31126 10 sfx(WAV_GASP);
31127 10 sfx(WAV_GANON);
31128 10 int32_t Id=0;
31129
31130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 790 times.
790 for(int32_t i=0; i<eMAXGUYS; i++)
31131 {
31132
2/2
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 10 times.
790 if(guysbuf[i].flags2&eneflag_ganon)
31133 {
31134 10 Id=i;
31135 10 break;
31136 }
31137 780 }
31138
31139
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(current_item(itype_ring))
31140 {
31141 8 addenemy(160,96,Id,0);
31142 8 }
31143 else
31144 {
31145 2 addenemy(80,32,Id,0);
31146 }
31147 10 }
31148
31149
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
2410 if(f==48)
31150 {
31151 10 lighting(true,true); // Hmm. -L
31152 10 f += 30;
31153 10 }
31154
31155 //NES Z1, the triforce vanishes for one frame in two cases
31156 //while still showing Hero's two-handed overhead sprite.
31157 //This should be a Quest Rule for NES Accuracy. -Z
31158
4/4
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 2390 times.
2410 if(f==255 || f==270)
31159 {
31160 20 holditem=-1;
31161 20 }
31162
31163
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
2410 if(f==256)
31164 {
31165 10 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
31166 10 }
31167
31168 2410 draw_screen(tmpscr);
31169 2410 advanceframe(true);
31170
31171
1/2
✓ Branch 0 taken 2410 times.
✗ Branch 1 not taken.
2410 if(rSbtn())
31172 {
31173 conveyclk=3;
31174 int32_t tmp_subscr_clk = frame;
31175 dosubscr();
31176 newscr_clk += frame - tmp_subscr_clk;
31177 }
31178
31179 2410 }
31180
31181 10 action=none; FFCore.setHeroAction(none);
31182 10 dir=up;
31183
31184
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
10 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
31185 2 jukebox(MAXMIDIS-1);
31186 else
31187 8 playLevelMusic();
31188
31189 10 currcset=DMaps[currdmap].color;
31190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (get_qr(qr_GANONINTRO) )
31191 {
31192 10 dointro();
31193 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
31194 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
31195 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
31196 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
31197 10 }
31198 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
31199 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
31200 //on a different DMap.
31201 //~ Otherwise, why is it here?! -Z
31202
31203
31204 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
31205 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
31206
31207 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
31208 //Users who use that dmap rule should put ganons room on its own DMap! -Z
31209 10 cont_sfx(WAV_ROAR);
31210 14 }
31211
31212 9 void HeroClass::win_game()
31213 {
31214
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 replay_step_comment("win_game");
31215 9 Playing=Paused=false;
31216 9 action=won; FFCore.setHeroAction(won);
31217 9 Quit=qWON;
31218 9 hclk=0;
31219 9 x = 136;
31220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 y = (isdungeon() && currscr<128) ? 75 : 73;
31221 9 z = fakez = fall = fakefall = spins = 0;
31222 9 dir=left;
31223 9 }
31224
31225 18080 void HeroClass::reset_swordcharge()
31226 {
31227 18080 charging=spins=tapping=0;
31228 18080 }
31229
31230 112579 void HeroClass::reset_hookshot()
31231 {
31232
10/12
✓ Branch 0 taken 64560 times.
✓ Branch 1 taken 48019 times.
✓ Branch 2 taken 64554 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 64525 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 64522 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 64522 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 64522 times.
112579 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
31233 {
31234 64522 action=none; FFCore.setHeroAction(none);
31235 64522 }
31236
31237 112579 hookshot_frozen=false;
31238 112579 hookshot_used=false;
31239 112579 pull_hero=false;
31240 112579 hs_fix=false;
31241 112579 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
31242 112579 switch_hooked = false;
31243
2/2
✓ Branch 0 taken 112578 times.
✓ Branch 1 taken 1 times.
112579 if(switching_object)
31244 1 switching_object->switch_hooked = false;
31245 112579 switching_object = NULL;
31246 112579 hooked_combopos = -1;
31247 112579 switchhook_cost_item = -1;
31248 112579 hooked_layerbits = 0;
31249
2/2
✓ Branch 0 taken 788053 times.
✓ Branch 1 taken 112579 times.
900632 for(auto q = 0; q < 7; ++q)
31250 788053 hooked_undercombos[q] = -1;
31251 112579 Lwpns.del(Lwpns.idFirst(wHSHandle));
31252 112579 Lwpns.del(Lwpns.idFirst(wHookshot));
31253 112579 chainlinks.clear();
31254
2/2
✓ Branch 0 taken 2480 times.
✓ Branch 1 taken 110099 times.
112579 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
31255 112579 hs_switcher = false;
31256
31257
2/2
✓ Branch 0 taken 105073 times.
✓ Branch 1 taken 7506 times.
112579 if(index>=0)
31258 {
31259 7506 stop_sfx(itemsbuf[index].usesound);
31260 7506 }
31261
31262 112579 hs_xdist=0;
31263 112579 hs_ydist=0;
31264 112579 }
31265
31266
31267 4606893 bool HeroClass::can_deploy_ladder()
31268 {
31269
2/2
✓ Branch 0 taken 1788374 times.
✓ Branch 1 taken 2818519 times.
7164593 bool ladderallowed = ((!get_qr(qr_LADDERANYWHERE) && (tmpscr->flags&fLADDER)) || isdungeon()
31270
4/4
✓ Branch 0 taken 577129 times.
✓ Branch 1 taken 2557700 times.
✓ Branch 2 taken 694873 times.
✓ Branch 3 taken 1862827 times.
2818519 || (get_qr(qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
31271
8/10
✓ Branch 0 taken 1775051 times.
✓ Branch 1 taken 3148152 times.
✓ Branch 2 taken 1358489 times.
✓ Branch 3 taken 416562 times.
✓ Branch 4 taken 1358420 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 1358420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1358420 times.
6281623 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
31272
2/2
✓ Branch 0 taken 1337740 times.
✓ Branch 1 taken 20680 times.
1358420 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
31273 }
31274
31275 6241046 void HeroClass::reset_ladder()
31276 {
31277 6241046 ladderx=laddery=0;
31278 6241046 }
31279
31280 bool is_conveyor(int32_t type);
31281 int32_t get_conveyor(int32_t x, int32_t y);
31282
31283 7262477 void HeroClass::check_conveyor()
31284 {
31285 7262477 ++newconveyorclk;
31286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7262477 times.
7262477 if (newconveyorclk < 0) newconveyorclk = 0;
31287
31288
14/18
✓ Branch 0 taken 7262477 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7262477 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7261837 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 7261837 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7261837 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7259262 times.
✓ Branch 11 taken 2575 times.
✓ Branch 12 taken 7258640 times.
✓ Branch 13 taken 622 times.
✓ Branch 14 taken 7254731 times.
✓ Branch 15 taken 3909 times.
✓ Branch 16 taken 7254731 times.
✓ Branch 17 taken 3909 times.
7262477 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
31289 {
31290 7746 is_conveyor_stunned = 0;
31291 7746 return;
31292 }
31293
31294 7254731 WalkflagInfo info;
31295 int32_t xoff,yoff;
31296 7254731 zfix deltax(0), deltay(0);
31297 7254731 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
31298
2/2
✓ Branch 0 taken 2412657 times.
✓ Branch 1 taken 4842074 times.
7254731 if(cmbid < 0)
31299 {
31300
2/2
✓ Branch 0 taken 4841363 times.
✓ Branch 1 taken 711 times.
4842074 if (conveyclk <= 0) is_on_conveyor=false;
31301 4842074 return;
31302 }
31303 2412657 newcombo const* cmb = &combobuf[cmbid];
31304 2412657 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
31305 2412657 bool custom_spd = (cmb->usrflags&cflag2);
31306
2/4
✓ Branch 0 taken 2412657 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2412657 times.
✗ Branch 3 not taken.
2412657 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
31307 {
31308 2412657 int32_t ctype=cmb->type;
31309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2412657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2412657 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31310
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2412657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2412657 if(custom_spd && (newconveyorclk % rate)) return;
31311
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2412657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2412657 if((cmb->usrflags&cflag5) && HasHeavyBoots())
31312 return;
31313 2412657 is_on_conveyor=false;
31314 2412657 conv_forcedir=-1;
31315 2412657 is_conveyor_stunned=0;
31316
31317 2412657 deltax=combo_class_buf[ctype].conveyor_x_speed;
31318 2412657 deltay=combo_class_buf[ctype].conveyor_y_speed;
31319
31320
3/4
✓ Branch 0 taken 2641 times.
✓ Branch 1 taken 2410016 times.
✓ Branch 2 taken 2641 times.
✗ Branch 3 not taken.
2412657 if (is_conveyor(ctype) && custom_spd)
31321 {
31322 deltax = zslongToFix(cmb->attributes[0]);
31323 deltay = zslongToFix(cmb->attributes[1]);
31324 }
31325
31326
8/8
✓ Branch 0 taken 2411233 times.
✓ Branch 1 taken 1424 times.
✓ Branch 2 taken 2410016 times.
✓ Branch 3 taken 1217 times.
✓ Branch 4 taken 83852 times.
✓ Branch 5 taken 2326164 times.
✓ Branch 6 taken 41491 times.
✓ Branch 7 taken 42361 times.
2412657 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
31327 {
31328 42361 cmbid = MAPCOMBO(x+8,y+16);
31329 42361 cmb = &combobuf[cmbid];
31330 42361 custom_spd = cmb->usrflags&cflag2;
31331 42361 ctype=(cmb->type);
31332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42361 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42361 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
31333 42361 deltax=combo_class_buf[ctype].conveyor_x_speed;
31334 42361 deltay=combo_class_buf[ctype].conveyor_y_speed;
31335
2/4
✓ Branch 0 taken 42361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42361 times.
✗ Branch 3 not taken.
42361 if ((deltax != 0 || deltay != 0) && custom_spd)
31336 {
31337 deltax = zslongToFix(cmb->attributes[0]);
31338 deltay = zslongToFix(cmb->attributes[1]);
31339 }
31340 42361 }
31341
31342
4/4
✓ Branch 0 taken 2411233 times.
✓ Branch 1 taken 1424 times.
✓ Branch 2 taken 2410016 times.
✓ Branch 3 taken 1217 times.
2412657 if(deltax!=0||deltay!=0)
31343 {
31344 2641 is_on_conveyor=true;
31345 2641 }
31346 2410016 else return;
31347
31348
1/2
✓ Branch 0 taken 2641 times.
✗ Branch 1 not taken.
2641 bool forcewalk = (cmb->usrflags&cflag6) && get_qr(qr_NEW_HERO_MOVEMENT2);
31349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2641 times.
2641 if(forcewalk)
31350 {
31351 is_conveyor_stunned = rate;
31352 if((cmb->usrflags&cflag3) && !spins)
31353 {
31354 if(abs(deltax) > abs(deltay))
31355 conv_forcedir = dir = (deltax > 0) ? right : left;
31356 else conv_forcedir = dir = (deltay > 0) ? down : up;
31357 }
31358 convey_forcex = deltax;
31359 convey_forcey = deltay;
31360 }
31361 else
31362 {
31363 2641 bool movedx = false, movedy = false;
31364
1/2
✓ Branch 0 taken 2641 times.
✗ Branch 1 not taken.
2641 if(cmb->usrflags&cflag4) //Smart corners
31365 {
31366 if(deltay<0)
31367 {
31368 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31369 execute(info);
31370
31371 if(!info.isUnwalkable())
31372 {
31373 movedy = true;
31374 zfix step(0);
31375
31376 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31377 {
31378 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31379 {
31380 yoff=int32_t(y-step)&7;
31381
31382 if(!yoff) break;
31383
31384 step++;
31385 }
31386 }
31387 else
31388 {
31389 step=abs(deltay);
31390 }
31391
31392 y=y-step;
31393 hs_starty-=step.getInt();
31394
31395 for(int32_t j=0; j<chainlinks.Count(); j++)
31396 {
31397 chainlinks.spr(j)->y-=step;
31398 }
31399
31400 if(Lwpns.idFirst(wHookshot)>-1)
31401 {
31402 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31403 }
31404
31405 if(Lwpns.idFirst(wHSHandle)>-1)
31406 {
31407 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31408 }
31409 }
31410 }
31411 else if(deltay>0)
31412 {
31413 info = walkflag(x,y+15+2,2,down);
31414 execute(info);
31415
31416 if(!info.isUnwalkable())
31417 {
31418 movedy = true;
31419 zfix step(0);
31420
31421 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31422 {
31423 while(step<abs(deltay))
31424 {
31425 yoff=int32_t(y+step)&7;
31426
31427 if(!yoff) break;
31428
31429 step++;
31430 }
31431 }
31432 else
31433 {
31434 step=abs(deltay);
31435 }
31436
31437 y=y+step;
31438 hs_starty+=step.getInt();
31439
31440 for(int32_t j=0; j<chainlinks.Count(); j++)
31441 {
31442 chainlinks.spr(j)->y+=step;
31443 }
31444
31445 if(Lwpns.idFirst(wHookshot)>-1)
31446 {
31447 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31448 }
31449
31450 if(Lwpns.idFirst(wHSHandle)>-1)
31451 {
31452 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31453 }
31454 }
31455 }
31456
31457 if(deltax<0)
31458 {
31459 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31460 execute(info);
31461
31462 if(!info.isUnwalkable())
31463 {
31464 movedx = true;
31465 zfix step(0);
31466
31467 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31468 {
31469 while(step<abs(deltax))
31470 {
31471 xoff=int32_t(x-step)&7;
31472
31473 if(!xoff) break;
31474
31475 step++;
31476 }
31477 }
31478 else
31479 {
31480 step=abs(deltax);
31481 }
31482
31483 x=x-step;
31484 hs_startx-=step.getInt();
31485
31486 for(int32_t j=0; j<chainlinks.Count(); j++)
31487 {
31488 chainlinks.spr(j)->x-=step;
31489 }
31490
31491 if(Lwpns.idFirst(wHookshot)>-1)
31492 {
31493 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31494 }
31495
31496 if(Lwpns.idFirst(wHSHandle)>-1)
31497 {
31498 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31499 }
31500 }
31501 }
31502 else if(deltax>0)
31503 {
31504 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31505 execute(info);
31506
31507 if(!info.isUnwalkable())
31508 {
31509 movedx = true;
31510 zfix step(0);
31511
31512 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31513 {
31514 while(step<abs(deltax))
31515 {
31516 xoff=int32_t(x+step)&7;
31517
31518 if(!xoff) break;
31519
31520 step++;
31521 }
31522 }
31523 else
31524 {
31525 step=abs(deltax);
31526 }
31527
31528 x=x+step;
31529 hs_startx+=step.getInt();
31530
31531 for(int32_t j=0; j<chainlinks.Count(); j++)
31532 {
31533 chainlinks.spr(j)->x+=step;
31534 }
31535
31536 if(Lwpns.idFirst(wHookshot)>-1)
31537 {
31538 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31539 }
31540
31541 if(Lwpns.idFirst(wHSHandle)>-1)
31542 {
31543 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31544 }
31545 }
31546 }
31547 if(deltax && !movedx && !deltay)
31548 {
31549 zfix oy = y;
31550 y = COMBOY(pos);
31551 bool validpush = scr_canmove(deltax, 0, false, false);
31552 zfix ny = handle_movestate_zfix([&]()
31553 {
31554 movexy(deltax,0,false,false,true,true);
31555 return y;
31556 });
31557 y = oy;
31558 if (validpush || ny != COMBOY(pos))
31559 {
31560 if (y <= ny-1)
31561 {
31562 setYfix(y+1);
31563 }
31564 else if (y >= ny+1)
31565 {
31566 setYfix(y-1);
31567 }
31568 else
31569 {
31570 setYfix(ny);
31571 }
31572 }
31573 }
31574 if(deltay && !movedy && !deltax)
31575 {
31576 zfix ox = x;
31577 x = COMBOX(pos);
31578 bool validpush = scr_canmove(0, deltay, false, false);
31579 zfix nx = handle_movestate_zfix([&]()
31580 {
31581 movexy(0,deltay,false,false,true,true);
31582 return x;
31583 });
31584 x = ox;
31585 if (validpush || nx != COMBOX(pos))
31586 {
31587 if (x <= nx-1)
31588 {
31589 setXfix(x+1);
31590 }
31591 else if (x >= nx+1)
31592 {
31593 setXfix(x-1);
31594 }
31595 else
31596 {
31597 setXfix(nx);
31598 }
31599 }
31600 }
31601 }
31602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2641 times.
2641 if(!movedy)
31603 {
31604
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 2169 times.
2641 if(deltay<0)
31605 {
31606 472 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
31607 472 execute(info);
31608
31609
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 446 times.
472 if(!info.isUnwalkable())
31610 {
31611 446 movedy = true;
31612 446 zfix step(0);
31613
31614
10/12
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 66 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
446 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31615 {
31616
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
31617 {
31618 11 yoff=int32_t(y-step)&7;
31619
31620
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(!yoff) break;
31621
31622 10 step++;
31623 }
31624 6 }
31625 else
31626 {
31627 440 step=abs(deltay);
31628 }
31629
31630 446 y=y-step;
31631 446 hs_starty-=step.getInt();
31632
31633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 446 times.
446 for(int32_t j=0; j<chainlinks.Count(); j++)
31634 {
31635 chainlinks.spr(j)->y-=step;
31636 }
31637
31638
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(Lwpns.idFirst(wHookshot)>-1)
31639 {
31640 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
31641 }
31642
31643
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if(Lwpns.idFirst(wHSHandle)>-1)
31644 {
31645 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
31646 }
31647 446 }
31648 26 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
31649 472 }
31650
2/2
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 745 times.
2169 else if(deltay>0)
31651 {
31652 745 info = walkflag(x,y+15+2,2,down);
31653 745 execute(info);
31654
31655
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 493 times.
745 if(!info.isUnwalkable())
31656 {
31657 493 movedy = true;
31658 493 zfix step(0);
31659
31660
9/12
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 172 times.
✓ Branch 3 taken 321 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 110 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 62 times.
493 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
31661 {
31662
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 104 times.
144 while(step<abs(deltay))
31663 {
31664 104 yoff=int32_t(y+step)&7;
31665
31666
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 22 times.
104 if(!yoff) break;
31667
31668 82 step++;
31669 }
31670 62 }
31671 else
31672 {
31673 431 step=abs(deltay);
31674 }
31675
31676 493 y=y+step;
31677 493 hs_starty+=step.getInt();
31678
31679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 for(int32_t j=0; j<chainlinks.Count(); j++)
31680 {
31681 chainlinks.spr(j)->y+=step;
31682 }
31683
31684
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 if(Lwpns.idFirst(wHookshot)>-1)
31685 {
31686 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
31687 }
31688
31689
1/2
✓ Branch 0 taken 493 times.
✗ Branch 1 not taken.
493 if(Lwpns.idFirst(wHSHandle)>-1)
31690 {
31691 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
31692 }
31693 493 }
31694 252 else checkdamagecombos(x,y+15);
31695 745 }
31696 2641 }
31697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2641 times.
2641 if(!movedx)
31698 {
31699
2/2
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 1602 times.
2641 if(deltax<0)
31700 {
31701 1039 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
31702 1039 execute(info);
31703
31704
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 870 times.
1039 if(!info.isUnwalkable())
31705 {
31706 870 movedx = true;
31707 870 zfix step(0);
31708
31709
9/12
✓ Branch 0 taken 778 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 800 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 46 times.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 24 times.
870 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31710 {
31711
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 43 times.
60 while(step<abs(deltax))
31712 {
31713 43 xoff=int32_t(x-step)&7;
31714
31715
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 7 times.
43 if(!xoff) break;
31716
31717 36 step++;
31718 }
31719 24 }
31720 else
31721 {
31722 846 step=abs(deltax);
31723 }
31724
31725 870 x=x-step;
31726 870 hs_startx-=step.getInt();
31727
31728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 870 times.
870 for(int32_t j=0; j<chainlinks.Count(); j++)
31729 {
31730 chainlinks.spr(j)->x-=step;
31731 }
31732
31733
1/2
✓ Branch 0 taken 870 times.
✗ Branch 1 not taken.
870 if(Lwpns.idFirst(wHookshot)>-1)
31734 {
31735 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
31736 }
31737
31738
1/2
✓ Branch 0 taken 870 times.
✗ Branch 1 not taken.
870 if(Lwpns.idFirst(wHSHandle)>-1)
31739 {
31740 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
31741 }
31742 870 }
31743 169 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
31744 1039 }
31745
2/2
✓ Branch 0 taken 1217 times.
✓ Branch 1 taken 385 times.
1602 else if(deltax>0)
31746 {
31747 385 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
31748 385 execute(info);
31749
31750
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 379 times.
385 if(!info.isUnwalkable())
31751 {
31752 379 movedx = true;
31753 379 zfix step(0);
31754
31755
9/12
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 317 times.
✓ Branch 4 taken 28 times.
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28 times.
379 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
31756 {
31757
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 53 times.
76 while(step<abs(deltax))
31758 {
31759 53 xoff=int32_t(x+step)&7;
31760
31761
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 5 times.
53 if(!xoff) break;
31762
31763 48 step++;
31764 }
31765 28 }
31766 else
31767 {
31768 351 step=abs(deltax);
31769 }
31770
31771 379 x=x+step;
31772 379 hs_startx+=step.getInt();
31773
31774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 379 times.
379 for(int32_t j=0; j<chainlinks.Count(); j++)
31775 {
31776 chainlinks.spr(j)->x+=step;
31777 }
31778
31779
1/2
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
379 if(Lwpns.idFirst(wHookshot)>-1)
31780 {
31781 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
31782 }
31783
31784
1/2
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
379 if(Lwpns.idFirst(wHSHandle)>-1)
31785 {
31786 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
31787 }
31788 379 }
31789 6 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
31790 385 }
31791 2641 }
31792
4/4
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 1249 times.
✓ Branch 2 taken 939 times.
✓ Branch 3 taken 453 times.
2641 if(movedx || movedy)
31793 {
31794
1/2
✓ Branch 0 taken 2188 times.
✗ Branch 1 not taken.
2188 if(cmb->usrflags&cflag1)
31795 is_conveyor_stunned = rate;
31796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2188 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2188 if((cmb->usrflags&cflag3) && !spins)
31797 {
31798 if(abs(deltax) > abs(deltay))
31799 conv_forcedir = dir = (deltax > 0) ? right : left;
31800 else conv_forcedir = dir = (deltay > 0) ? down : up;
31801 }
31802 2188 }
31803 }
31804 2641 }
31805 7262477 }
31806
31807 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
31808 {
31809 DivineProtectionShieldClk=newclk;
31810
31811 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
31812 {
31813 decoration *dec;
31814 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31815 decorations.spr(decorations.Count()-1)->misc=0;
31816 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
31817 dec=(decoration *)decorations.spr(decorations.Count()-1);
31818 decorations.spr(decorations.Count()-1)->misc=1;
31819 }
31820 }
31821
31822 16354 int32_t HeroClass::getDivineProtectionShieldClk()
31823 {
31824 16354 return DivineProtectionShieldClk;
31825 }
31826
31827 21 int32_t HeroClass::getHoverClk()
31828 {
31829 21 return hoverclk;
31830 }
31831
31832 10668751 int32_t HeroClass::getHoldClk()
31833 {
31834 10668751 return holdclk;
31835 }
31836
31837 4477092 int32_t HeroClass::getLastLensID(){
31838 4477092 return last_lens_id;
31839 }
31840
31841 209 void HeroClass::setLastLensID(int32_t p_item){
31842 209 last_lens_id = p_item;
31843 209 }
31844
31845 60362884 bool HeroClass::getOnSideviewLadder()
31846 {
31847 60362884 return on_sideview_ladder;
31848 }
31849
31850 23 void HeroClass::setOnSideviewLadder(bool val)
31851 {
31852
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(val)
31853 {
31854 fall = fakefall = hoverclk = jumping = 0;
31855 hoverflags = 0;
31856 inair = false;
31857 }
31858 23 on_sideview_ladder = val;
31859 23 }
31860
31861 2206072 bool HeroClass::canSideviewLadder(bool down)
31862 {
31863
2/2
✓ Branch 0 taken 2172165 times.
✓ Branch 1 taken 33907 times.
2206072 if(!isSideViewHero()) return false;
31864
2/2
✓ Branch 0 taken 20701 times.
✓ Branch 1 taken 13206 times.
33907 if(jumping < 0) return false;
31865
3/4
✓ Branch 0 taken 8519 times.
✓ Branch 1 taken 12182 times.
✓ Branch 2 taken 8519 times.
✗ Branch 3 not taken.
20701 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
31866 {
31867 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31868 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
31869 }
31870 //Are you presently able to climb a sideview ladder?
31871 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31872 //y+0 checks your top-half for large hitbox; y+8 for small
31873 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31874 //y+16 check is for going down onto a ladder you are standing on.
31875
1/2
✓ Branch 0 taken 20701 times.
✗ Branch 1 not taken.
41402 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
31876
2/4
✓ Branch 0 taken 20701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20701 times.
✗ Branch 3 not taken.
20701 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
31877
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20701 times.
✓ Branch 2 taken 12182 times.
✓ Branch 3 taken 8519 times.
✓ Branch 4 taken 8519 times.
✗ Branch 5 not taken.
29220 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
31878 2206072 }
31879
31880 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
31881 {
31882 if(!isSideViewHero()) return false;
31883 if(jumping < 0) return false;
31884 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
31885 {
31886 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
31887 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
31888 }
31889 //Are you presently able to climb a sideview ladder?
31890 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
31891 //y+0 checks your top-half for large hitbox; y+8 for small
31892 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
31893 //y+16 check is for going down onto a ladder you are standing on.
31894 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
31895 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
31896 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
31897 }
31898
31899 4615780 void HeroClass::execute(HeroClass::WalkflagInfo info)
31900 {
31901 4615780 int32_t flags = info.getFlags();
31902
31903
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 4615127 times.
4615780 if(flags & WalkflagInfo::CLEARILSWIM)
31904 653 ilswim =false;
31905
2/2
✓ Branch 0 taken 4613318 times.
✓ Branch 1 taken 1809 times.
4615127 else if(flags & WalkflagInfo::SETILSWIM)
31906 1809 ilswim = true;
31907
31908
1/2
✓ Branch 0 taken 4615780 times.
✗ Branch 1 not taken.
4615780 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
31909 {
31910 charging = 0;
31911 attackclk = 0;
31912 }
31913
31914
1/2
✓ Branch 0 taken 4615780 times.
✗ Branch 1 not taken.
4615780 if(flags & WalkflagInfo::SETDIR)
31915 {
31916 dir = info.getDir();
31917 }
31918
31919
2/2
✓ Branch 0 taken 4615190 times.
✓ Branch 1 taken 590 times.
4615780 if(flags & WalkflagInfo::SETHOPCLK)
31920 {
31921 590 hopclk = info.getHopClk();
31922 590 }
31923
31924
2/2
✓ Branch 0 taken 4614698 times.
✓ Branch 1 taken 1082 times.
4615780 if(flags & WalkflagInfo::SETHOPDIR)
31925 {
31926 1082 hopdir = info.getHopDir();
31927 1082 }
31928
31929 4615780 }
31930
31931 9638674 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
31932 {
31933 9638674 HeroClass::WalkflagInfo ret;
31934 9638674 ret.newhopclk = newhopclk;
31935 9638674 ret.newdir = newdir;
31936
2/2
✓ Branch 0 taken 7959149 times.
✓ Branch 1 taken 1679525 times.
9638674 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31937
31938 9638674 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
31939 9638674 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
31940 9638674 ret.flags = flags1 | flags2;
31941 9638674 return ret;
31942 }
31943
31944 59062 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
31945 {
31946 59062 HeroClass::WalkflagInfo ret;
31947 59062 ret.newhopclk = newhopclk;
31948 59062 ret.newdir = newdir;
31949
1/2
✓ Branch 0 taken 59062 times.
✗ Branch 1 not taken.
59062 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
31950
31951 59062 ret.flags = flags & other.flags;
31952 59062 return ret;
31953 }
31954
31955 59062 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
31956 {
31957 59062 HeroClass::WalkflagInfo ret;
31958 59062 ret.newhopclk = newhopclk;
31959 59062 ret.newdir = newdir;
31960 59062 ret.newhopdir = newhopdir;
31961
31962 59062 ret.flags = flags ^ UNWALKABLE;
31963 59062 return ret;
31964 }
31965
31966 void HeroClass::explode(int32_t type)
31967 {
31968 static int32_t tempx, tempy;
31969 static byte herotilebuf[256];
31970 int32_t ltile=0;
31971 int32_t lflip=0;
31972 bool shieldModify=true;
31973 unpack_tile(newtilebuf, tile, flip, true);
31974 memcpy(herotilebuf, unpackbuf, 256);
31975 tempx=Hero.getX();
31976 tempy=Hero.getY();
31977 for(int32_t i=0; i<16; ++i)
31978 {
31979 for(int32_t j=0; j<16; ++j)
31980 {
31981 if(herotilebuf[i*16+j])
31982 {
31983 if(type==0) // Twilight
31984 {
31985 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
31986 int32_t k=particles.Count()-1;
31987 particle *p = (particles.at(k));
31988 p->step=3;
31989 }
31990 else if(type ==1) // Sands of Hours
31991 {
31992 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
31993 int32_t k=particles.Count()-1;
31994 particle *p = (particles.at(k));
31995 p->step=4;
31996
31997 if(zc_oldrand()%10 < 2)
31998 {
31999 p->color=1;
32000 p->cset=0;
32001 }
32002 }
32003 else
32004 {
32005 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
32006
32007 int32_t k=particles.Count()-1;
32008 particle *p = (particles.at(k));
32009 p->angular=true;
32010 p->angle=zc_oldrand();
32011 p->step=(((double)j)/8);
32012 p->yofs=Hero.getYOfs();
32013 }
32014 }
32015 }
32016 }
32017 }
32018
32019 1035 void HeroClass::SetSwim()
32020 {
32021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1035 times.
1035 if (CanSideSwim())
32022 {
32023 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
32024 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32025 if (get_qr(qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
32026 }
32027 1035 else {action=swimming; FFCore.setHeroAction(swimming);}
32028 1035 }
32029
32030 65322 void HeroClass::SetAttack()
32031 {
32032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65322 times.
65322 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
32033 65322 else {action=attacking; FFCore.setHeroAction(attacking);}
32034 65322 }
32035
32036 60099616 bool HeroClass::IsSideSwim()
32037 {
32038
6/12
✓ Branch 0 taken 60099616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60099616 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60099616 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60099616 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60099616 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60099616 times.
60099616 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
32039 }
32040
32041 1878875 bool HeroClass::CanSideSwim()
32042 {
32043
1/2
✓ Branch 0 taken 1878875 times.
✗ Branch 1 not taken.
1878875 return (isSideViewHero() && get_qr(qr_SIDESWIM));
32044 }
32045
32046 6051811 int32_t HeroClass::getTileModifier()
32047 {
32048 6051811 return item_tile_mod() + bunny_tile_mod();
32049 }
32050 void HeroClass::setImmortal(int32_t nimmortal)
32051 {
32052 immortal = nimmortal;
32053 }
32054 void HeroClass::kill(bool bypassFairy)
32055 {
32056 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
32057 }
32058 21811214 bool HeroClass::sideview_mode() const
32059 {
32060
3/4
✓ Branch 0 taken 759072 times.
✓ Branch 1 taken 21052142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 759072 times.
21811214 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
32061 }
32062 2424 bool HeroClass::is_unpushable() const
32063 {
32064 2424 return toogam;
32065 }
32066